Skip to content

Instantly share code, notes, and snippets.

@ptrcnull
Last active June 30, 2024 11:14
Show Gist options
  • Save ptrcnull/06d67d6fe202202dde6f678e6c755b2b to your computer and use it in GitHub Desktop.
Save ptrcnull/06d67d6fe202202dde6f678e6c755b2b to your computer and use it in GitHub Desktop.
EicServerProxy notes

sklad

https://bilet.intercity.pl/EicServerProxy?service=sklad
	&kategoria=IC
	&numer=4122
	&dataWyjazduPociagu=202307160859
	&dataPrzyjazduPociagu=202307161322
	&stacjaOd=5100042
	&stacjaDo=5100136
	&typSkladu=ED161

dataWyjazduPociagu/dataPrzyjazduPociagu is just YYYYMMDDHHmm

typSkladu can be one of the following: WAGONOWY, ED161, ED160; for some reason, ED250 uses ED160 internally

stacjaOd/stacjaDo is UIC/EPA code, you can find that:

  • on wikidata with the following query:
SELECT DISTINCT ?item ?statement ?propertyValue WHERE {
  ?statement ps:P954 "${hafasCode}".
  ?item p:P954 ?statement;
    wdt:P722 ?propertyValue.
  }

where it's property P722 ("UIC station code")

  • by using the intercity.pl search api:
curl -A '' 'https://www.intercity.pl/station/get/?q=katowice'

the WAF for intercity.pl blocks curl user agent, but setting an empty one works just fine

wagon/svg

https://bilet.intercity.pl/EicServerProxy?service=wagon/svg
	&kategoria=IC
	&numer=4122
	&wagon=6
	&dataWyjazduPociagu=202307160859
	&dataPrzyjazduPociagu=202307161322
	&data=20230716
	&stacjaOd=25
	&stacjaDo=90
	&typSkladu=ED161
	&nrSkladu=

same as above, except:

  • nrSkladu is empty for EMUs, but for other cases it's taken from the wagonySchemat field from sklad query for the respective train car
  • station codes here are slightly different for non-EMU trains it's just the same as in sklad, but in this example Katowice is 25 and Warszawa Centralna is 90; this is an index of the station in the trip ( starting from 1 and the first station of the entire train trip, multiplied by 5 )
  • there's an additional data field which is just the YYYYMMDD date, for some reason

this request returns an SVG where every seat fetches a png file (thanks, devs); in the SVG file there's also a script that handles picking a seat and reveals what some filenames mean:

var p1Img = {
  R: imgServerUrl + '1R.png',
  L: imgServerUrl + '1L.png',
  U: imgServerUrl + '1U.png',
  B: imgServerUrl + '1B.png',
} /* niedostępne miejsce */
var unavailableImg = {
  R: imgServerUrl + '3R.png',
  L: imgServerUrl + '3L.png',
  U: imgServerUrl + '3U.png',
  B: imgServerUrl + '3B.png',
}
/* wybrane miejsce */ var chosenImg = {
  R: imgServerUrl + '2R.png',
  L: imgServerUrl + '2L.png',
  U: imgServerUrl + '2U.png',
  B: imgServerUrl + '2B.png',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment