Sessions
In general every request you make will be billed and counted. We have implemented a way to save money by using what we call sessions. The idea is that repeated requests to the same resource will be less relevant for you and if these requests happen during one session block (a time interval) only one of them will be counted.
At the moment, departure board queries to the same station and trip updates for the same trip id will use the session block counting mechanism. Other requests will be counted per request. This is also strictly optional. You don't have to use it.
Hint: If you use Mobilitybox.js you will automatically benefit from session without any change from you.
Example:
1. Request departures for a certain station:
/* Request */
curl -X GET "https://api.themobilitybox.com/v3/transit/departures.json?station_id=vesputi-station-OW_67U4PIKCwCBxtnNWwZ2jnsNS2WZA1eNY9MyjyvKs&api_key=abcde-fghi-jkln-mnop" -H "accept: application/json" -D -
[...]
/* Response */
HTTP/2 200
date: Wed, 02 Jun 2021 06:16:53 GMT
content-type: application/json; charset=utf-8
access-control-allow-origin: *
session-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vYXB...
[...]
[{"departure":{"scheduled_at":1622617380000,"predicted_at":null,"platform":""},"trip":{"id":
[...]
This first request is counted. As you can see, the response contains a header field called session-token.
2. Use session-token in subsequent requests:
curl -X GET "https://api.themobilitybox.com/v3/transit/departures.json?station_id=vesputi-station-OW_67U4PIKCwCBxtnNWwZ2jnsNS2WZA1eNY9MyjyvKs&api_key=abcde-fghi-jkln-mnop" \
-H "accept: application/json" \
-H "session-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vYXB..." \
-D -
This second request won't be counted if the request happens in a certain time window (5 minutes at the moment).
Important: Please always update the session-token with the header value you receive from subsequent requests as we do not gurantee that it won't change.