SAVEA Ticket API

SAVEA TICKET API

Preface

SAVEA provides a ticket API. This is done in the following proccess:

   (0. Fetch company specific 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. <-- read this if you wonder about the structure of the api

TRAINHACK: During the event, direct any questions to @vladdeSV, or mail vladde@savea.se :^)

Searchable company URLs

Company URL prefixes:
=====================

  • barabuss         // test site
  • blaklintsbuss
  • bergkvarabuss
  • silverlinjen
  • masexpressen
  • harjedalingen
  • lapplandspilen
  • sgsbussen
  • svenskabuss
  • vastervikexpress
  • skaraborgaren
  • fjallexpressen
  • Tapanis
  • Lindbergsbuss
  • Nikkaluotaexpressen

Currently not active, but available:

  • nikkaluoktaexpressen
  • sagarail

URL:
====
{company}.samtrafiken.savea.se    // example: barabuss.samtrafiken.savea.se

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/productcat/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/product
Example payload:

{
    "productId": "{product id}", //example id: 38368-223-219-39460-219-224/15-1
    "apiKey": "{trafiklab 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.