API
runsten-api serves a JSON API under /api/v1, for the web interface and for your scripts: it reads the vehicles and their events, and writes the account's settings and the costs of charges.
The API is described by an OpenAPI 3.1 document, api/openapi.yaml: routes, parameters, schemas, error codes, and what the fields mean. Clients can generate their types from it, for instance with npx openapi-typescript api/openapi.yaml -o api.ts.
Signing in
Every route requires a session: sign in with POST /api/v1/session, which sets the session cookie, and send the cookie back.
curl -c jar -H 'Content-Type: application/json' \
-d '{"username":"admin","password":"…"}' http://127.0.0.1:8081/api/v1/session
curl -b jar http://127.0.0.1:8081/api/v1/vehiclesA program can send a personal access token instead, created in the settings under API access: Authorization: Bearer rst_…. A token reads what the session reads, but the session's and the tokens' routes, at most 120 requests at once then 2 per second. It changes nothing, unless it was created with May mark the trips' purpose (the scope trips:mark), which allows PUT /api/v1/vehicles/{id}/trip-marks alone; a token created with May receive notifications (the scope notifications) registers its device, its Live Activities and sets the notification preferences (PUT, DELETE /api/v1/devices/{id}, PUT /api/v1/devices/{id}/live-activity-token, PUT /api/v1/devices/{id}/live-activities/{vehicle}, PUT /api/v1/notification-preferences); any other write answers 403 insufficient_scope.
curl -H 'Authorization: Bearer rst_…' http://127.0.0.1:8081/api/v1/vehiclesA request body is sent as application/json, but the files of an import, as multipart/form-data.
Routes
| Route | |
|---|---|
GET, POST, DELETE /api/v1/session | the current session; sign in; sign out |
GET /api/v1/vehicles, …/vehicles/{id} | the vehicles, their model, their sheet (colour, specifications, the name a Tesla's owner gave it), the state of their connection (Volvo, Polestar or Tesla) and what the collector did on its latest pass |
GET /api/v1/vehicles/{id}/picture | the vehicle's picture, relayed from its maker (a Volvo's) or read by the collector and stored (a BMW's), when its sheet.picture is true |
GET /api/v1/vehicles/{id}/variants | the catalog's variants of the vehicle's family (of its brand, for a Polestar of the Data Portal), the candidates of the recognition first |
PUT /api/v1/vehicles/{id}/model | choose the variant and the onboard charger (null for the recognition, and for a charger not stated) |
GET /api/v1/vehicles/{id}/state | the latest known values: SoC, range, odometer, position, charging, each with when it was read |
GET /api/v1/vehicles/{id}/trips, …/charges | newest first, by pages (limit, cursor), within a period (from, to) |
GET /api/v1/vehicles/{id}/trips/{trip}, …/charges/{charge} | one trip or charge |
GET /api/v1/vehicles/{id}/trips.csv, …/charges.csv | the trips or charges of a period (from, to; the charges of a place) as a CSV file, oldest first |
GET /api/v1/vehicles/{id}/readings.csv | every value the vehicle reported within a period (from, to, both required, a month at most) as a CSV file, one row per value: fetched_at, source, endpoint, field, value (Exporting your data) |
GET /api/v1/vehicles/{id}/charging | the charge in progress, null when none: what it added so far, its power, its cost so far, and read_at, its latest reading; not an event of the list, which has it under the same id once over |
GET /api/v1/vehicles/{id}/trips/{trip}/track | the track of an imported trip, a GeoJSON LineString; 404 for a trip without one |
PUT, DELETE /api/v1/vehicles/{id}/charges/{charge}/cost | enter what a charge cost; delete it |
GET /api/v1/vehicles/{id}/imports, DELETE …/imports/{source} | the trips and charges imported from other apps, by source; delete one source's |
POST /api/v1/vehicles/{id}/aximote-vehicles | the vehicles of an Aximote account, the token in the body; the one with the vehicle's VIN marked |
POST, GET /api/v1/vehicles/{id}/import-job | import the vehicle's history from Aximote, in the background (202, 409 while one runs); its progress and report |
POST /api/v1/vehicles/{id}/imports/volvo_data_portal | import the files of the Volvo Data Portal, at once: a multipart/form-data body with the trips file and, optionally, the waypoints file (32 MiB at most); the report |
POST /api/v1/vehicles/{id}/imports/aaos_logging | import the export of AAOS Logging, at once: a multipart/form-data body with the export file, the ZIP Google Drive gives for the car's folder (512 MiB at most); the report |
GET /api/v1/vehicles/{id}/stats | totals of a period (from, to) and the odometer at its ends, by day, week or month in a time zone (bucket, tz) |
GET /api/v1/vehicles/{id}/parked | the stops of a period (from, to), newest first: the parked intervals behind the statistics' loss while parked, each with its time, its loss, its power, its time asleep, its temperature and the events around it |
GET /api/v1/vehicles/{id}/battery | the estimated battery capacity over the whole history |
GET, PUT /api/v1/settings | the account's currency, and the accepted ones |
GET, POST /api/v1/places | the places, with their tariffs; create one |
GET, PUT, DELETE /api/v1/places/{place} | one place; replace it whole, tariff included; delete it |
GET /api/v1/places/{place}/unpriced | the place's charges that started before its tariff's first day |
GET /api/v1/instance | the release the instance runs and a newer one, its map tiles (map_tiles: the tiles' url and their attribution, null when the instance has no maps, see Maps), and whether it sends push notifications (notifications) |
PUT, DELETE /api/v1/devices/{id} | register the device an app runs on, its ID drawn by the app (platform apns or fcm, its push token, locale, app_version); remove it |
PUT /api/v1/devices/{id}/live-activity-token | the token the device's push service starts a charge's Live Activity with (iOS's push-to-start token); null: none is started |
PUT /api/v1/devices/{id}/live-activities/{vehicle} | the Live Activity the device shows of the vehicle's charge in progress (charge, its push token, null once dismissed): the instance updates it at each new reading, at least 50 seconds apart, and ends it once the charge is over; only figures go out. The kind charge_live_activity of the notification preferences turns them off for a vehicle. Revoking the access token a device registered with removes the device |
GET, PUT /api/v1/notification-preferences | what the user is told of: the account's kinds, a default for every vehicle, each vehicle's own choice (on, off, default); a PUT sets the kinds it lists, and leaves the others |
GET /api/v1/charge-costs/orphans | the entered costs that no charge takes any more |
PUT /api/v1/charge-costs/orphans/{cost}/charge, DELETE …/orphans/{cost} | attach one to a charge; delete it |
Conventions
- Units are in the field names:
_km,_m,_kwh,_pct,_w,_kw,_s;_minorin minor units of the account's currency (cents),price_per_kwhin its major units. - Times are RFC 3339 in UTC. Trip and charge times are bounds:
start.after,start.before,end.after,end.before.reconstructedmarks the events that were never seen. - Imported events come in the same lists as the derived ones, with
imported: true: trips and charges another app (Aximote, the Volvo Cars app) or Volvo Cars' Data Portal cut from its own readings, before Runsten read the vehicle. Their times are exact (afterequalsbefore), and their ID is their source and their ID there,aximote:8812.sourcestells where every event comes from: the sources of a derived event's readings (volvo), or the app of an imported one. - Unknown is
null, never zero. - Energies are estimates: ΔSoC ×
capacity_kwh, withcapacity_sourcecatalog_net(the net capacity of the variant) orapi(the capacity the car reports, a Volvo's). - Durations are
{"min", "max"}in seconds. - A cost is
{"currency", "min_minor", "max_minor", "source", …},min_minor = max_minorwhen it is one amount;sourceistariff,entered, orimported(what the app of an imported charge says it cost, in the account's currency). - Statistics count each event once, in the interval that holds its
start.after; a sum's_unknowncompanion counts the events that lacked a value. At most 400 intervals;tzis an IANA time zone,UTCby default. - Errors are
{"error": {"code": …, "message": …}}.