Collection examples¶
The eight exports of the datahub spec feed a data warehouse from a group's operations. This page gives a runnable example for each, in the language selected in the header — currently cURL.
Every example authenticates with an API key, sent in the Authorization header. The Authentication page describes how to obtain one. They read their inputs from the environment:
| Variable | Content |
|---|---|
GROUP_ID |
The identifier of the group to export |
PYSAE_API_KEY |
The API key carrying the export rights |
Before you start: the signatures differ¶
The eight exports are not called the same way. Three families coexist, and no generic call covers all eight.
| Export | Parameters |
|---|---|
trips |
date (required) |
trip-km, passenger-counts |
start_date, end_date (required) |
punctuality, trip-tracking |
start_date (required), end_date |
drivers, vehicles, alerts |
no required parameter |
Write dates in the compact YYYYMMDD form — for example 20260131. It is the only format the five dated endpoints all accept. punctuality and trip-tracking also tolerate YYYY-MM-DD, but the other three reject it: sticking to the compact form saves you from remembering which is which.
The guide's Statistics and exports page details what each one returns.
Operated trips¶
GET /api/v4/groups/{group_id}/export/trips covers a single day, given by date. To cover a period, chain one call per day.
curl --fail --location \
--header "Authorization: Api-Key ${PYSAE_API_KEY}" \
"https://api.pysae.com/api/v4/groups/${GROUP_ID}/export/trips?date=20260131" \
--output trips.csv
Kilometres covered¶
GET /api/v4/groups/{group_id}/export/trip-km bounds a period with start_date and end_date, both required.
curl --fail --location \
--header "Authorization: Api-Key ${PYSAE_API_KEY}" \
"https://api.pysae.com/api/v4/groups/${GROUP_ID}/export/trip-km?start_date=20260101&end_date=20260131" \
--output trip-km.csv
Passenger counts¶
GET /api/v4/groups/{group_id}/export/passenger-counts follows the same signature as kilometres.
curl --fail --location \
--header "Authorization: Api-Key ${PYSAE_API_KEY}" \
"https://api.pysae.com/api/v4/groups/${GROUP_ID}/export/passenger-counts?start_date=20260101&end_date=20260131" \
--output passenger-counts.csv
Punctuality¶
GET /api/v4/groups/{group_id}/export/punctuality only requires start_date. The endpoint also accepts optional filters — event, stop_id, gtfs_id, driver_id, route_id — to narrow the export.
curl --fail --location \
--header "Authorization: Api-Key ${PYSAE_API_KEY}" \
"https://api.pysae.com/api/v4/groups/${GROUP_ID}/export/punctuality?start_date=20260101&end_date=20260131" \
--output punctuality.csv
Trip tracking¶
GET /api/v4/groups/{group_id}/export/trip-tracking requires start_date and end_date.
curl --fail --location \
--header "Authorization: Api-Key ${PYSAE_API_KEY}" \
"https://api.pysae.com/api/v4/groups/${GROUP_ID}/export/trip-tracking?start_date=20260101&end_date=20260131" \
--output trip-tracking.csv
Drivers¶
GET /api/v4/groups/{group_id}/export/drivers exports the driver reference, with no notion of period. The optional archived parameter includes archived drivers, absent by default.
curl --fail --location \
--header "Authorization: Api-Key ${PYSAE_API_KEY}" \
"https://api.pysae.com/api/v4/groups/${GROUP_ID}/export/drivers" \
--output drivers.csv
Vehicles¶
GET /api/v4/groups/{group_id}/export/vehicles exports the fleet. The optional statuses parameter narrows it to vehicles in a given state.
curl --fail --location \
--header "Authorization: Api-Key ${PYSAE_API_KEY}" \
"https://api.pysae.com/api/v4/groups/${GROUP_ID}/export/vehicles" \
--output vehicles.csv
Alerts¶
GET /api/v4/groups/{group_id}/export/alerts exports the group's passenger information messages. No parameters.
curl --fail --location \
--header "Authorization: Api-Key ${PYSAE_API_KEY}" \
"https://api.pysae.com/api/v4/groups/${GROUP_ID}/export/alerts" \
--output alerts.csv
In production¶
- Split long periods. A monthly slice resumes after a failure; a yearly export starts over.
- Do not set a short timeout. Responses are streamed and a wide export takes time to start: a client enforcing a tight deadline cuts the connection before the first row.
- Replaying an export has no side effect. These endpoints are read-only.
- Check the key's perimeter. A key restricted to certain teams exports fewer rows, with nothing in the response to say so.