Skip to content

Instantly share code, notes, and snippets.

@kjagiello
Created February 4, 2020 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kjagiello/f9f436e97addfe70a3846de5e96f8bb4 to your computer and use it in GitHub Desktop.
Save kjagiello/f9f436e97addfe70a3846de5e96f8bb4 to your computer and use it in GitHub Desktop.
Retrieves train traffic deviations between Uppsala and Stockholm for yesterday
#!/usr/bin/env bash
curl \
-X POST \
-H 'Content-Type:application/xml' \
-d @query-announcements.xml \
--silent \
http://api.trafikinfo.trafikverket.se/v1.3/data.json | jq -r '.RESPONSE.RESULT[0].TrainAnnouncement[0].Deviation | .[]'
<REQUEST>
<LOGIN authenticationkey="716ac6ce0aca41708cefc9b00d62eb1e" />
<QUERY objecttype="TrainAnnouncement">
<DISTINCT>Deviation</DISTINCT>
<FILTER>
<OR>
<EQ name="FromLocation.LocationName" value="U" />
<EQ name="FromLocation.LocationName" value="Cst" />
</OR>
<OR>
<EQ name="ToLocation.LocationName" value="Cst" />
<EQ name="ToLocation.LocationName" value="U" />
</OR>
<GTE name="AdvertisedTimeAtLocation" value="$dateadd(-1.00:00)" />
</FILTER>
</QUERY>
</REQUEST>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment