SAVEA Express Bus Ticket API
500 tickets sold per company = get 10 000 SEK
Table of Contents
Preface
Searchable companies
Available stops
Get traveller types
Search departures
Create payment link
Send user to payment URL
Preface
SAVEA provides a ticket API. This is done in the following proccess:
(0. Fetch company specific information (available stops / traveller types))
1. Search departures
2. Request payment link
3. User pays for trip on payment link
Searching for departures partly follows Samtrafiken's BoB standard.
Searchable company URLs
Company URL prefixes:
=====================
barabuss // test site
blaklintsbuss
bergkvarabuss
silverlinjen
masexpressen
harjedalingen
lapplandspilen
sgsbussen
svenskabuss
vastervikexpress
skaraborgaren
fjallexpressen
tapanis
lindbergsbuss
nikkaluoktaexpressen
(currently not active, but available)
sagarail
URL:
====
http://{company}.samtrafiken.savea.se // example: http://barabuss.samtrafiken.savea.se
Get available stops
GET http://{company}.samtrafiken.savea.se/api/v1/stop
---
Example response:
[
{
"name": "Stockholm, Cityterminalen",
"lat": "59.33020",
"lon": "18.05910",
"rdb_id": "7400622"
},
...
]
Get traveller types
GET http://{company}.samtrafiken.savea.se/api/v1/productcat/travellers
---
Example response:
{
"15": "Vuxen",
...
}
Search departures
POST http://{company}.samtrafiken.savea.se/api/v1/product
Example payload:
{
"route": [
{
"stopId": "7400020" //stop RDB (riksdatabasen) number (9 or 7 digits)
},
{
"stopId": "740000622"
}
],
"travellersPerCategory": [
{
"cat": "15", // traveller type
"tra": 1 // traveller count
}
],
"temporal": {
"earliestDepature": "2018-10-19T12:00:00Z", //departure leaving earliest (timestamp described in RFC 3339 (https://www.ietf.org/rfc/rfc3339.txt §5.8))
"latestArrival": "2018-10-19T23:59:59Z" //departure arriving latest
}
}
---
Response:
[
[
{
"productId": "38368-223-219-39460-219-224/15-1",
"productDescription": "Biljett: Hållplats A → Hållplats B",
"fares": [
{
"amount": 261,
"currency": "SEK",
"vatAmount": 14.77,
"vatPercent": 6
}
],
"productProperties": {
"date": "2018-10-19T14:00:00+02:00"
},
"travellersPerCategory": [
[
{
"cat": "15",
"tra": "1"
}
]
]
},
{
"productId": "38732-223-219-39824-219-224/15-1",
"productDescription": "Biljett: Hållplats A → Hållplats B",
"fares": [
{
"amount": 106,
"currency": "SEK",
"vatAmount": 6.00,
"vatPercent": 6
}
],
"productProperties": {
"date": "2018-10-19T17:00:00+02:00"
},
"travellersPerCategory": [
[
{
"cat": "15",
"tra": "1"
}
]
]
},
...
]
]
Create payment link
POST http://{company}.samtrafiken.savea.se/api/v1/buy
Example payload:
{
"productId": "{product id}", //example id: 38368-223-219-39460-219-224/15-1
"apiKey": "{API key}"
}
---
Example response:
{
"payUrl": "{payment url}"
}
Send user to payment URL
// send user to url. user pays, and gets ticket
During development, to test a purchase:
1. Use the company barabuss
2. Search a trip from Kalmar Centralstation (7400020) to Örebro Centralstation (7400133)
3. Use payment method 'Faktura' and enter social security number 460509-2222.