Skip to content

Instantly share code, notes, and snippets.

@jbelien
Last active May 1, 2024 09:53
Show Gist options
  • Save jbelien/a92b5f0f2457b178ca5b1a988bb54698 to your computer and use it in GitHub Desktop.
Save jbelien/a92b5f0f2457b178ca5b1a988bb54698 to your computer and use it in GitHub Desktop.

STIB API

Create token

  1. Go to https://opendata.stib-mivb.be/store/subscriptions
  2. Click on "Generate keys"
  3. Encode ConsumerKey:consumerSecret in Base64 ; you can use https://codebeautify.org/base64-encode to encode it
  4. Replace BASE64KEY+:+SECRET by the generated Base64 and run the following command :
curl -k -d "grant_type=client_credentials" -H "Authorization: Basic BASE64KEY+:+SECRET" https://opendata-api.stib-mivb.be/token

The output will be something like :

{"access_token":"FrEfUwavAbUTaqeBUwR7dr3c5eNECutA","scope":"am_application_scope default","token_type":"Bearer","expires_in":3600}

Request GTFS data

  1. Replace TOKEN by previously generated token and run the following command :
curl -k -X GET --header "Accept: application/zip" --header "Authorization: Bearer TOKEN" -o ./gtfs.zip "https://opendata-api.stib-mivb.be/Files/1.0/Gtfs"
  1. GTFS data will be downloaded in gtfs.zip file !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment