Skip to content
Scrappa Get API key
Trainline API 1 credit/request

Trainline Best Fares API Documentation

GET https://scrappa.co/api/trainline/fares/best

Trainline Best Fares API Documentation Read the list of popular routes with the lowest fare, the duration and the path of the route on the Trainline site. The list is small and fixed. Use the fare calendar for a route of your own.

Trainline Best Fares API Documentation 1 credit/request

Endpoint

Request preview
GET
https://scrappa.co/api/trainline/fares/best
Auth header
x-api-key
Cost
1 credit/request
Response preview
200 OK
{
    "data": {
        "fares": [
            {
                "path": "/train-times/london-to-paris",
                "origin": {
                    "name": "London"
                },
                "is_reverse": true,
                "price_from": {
                    "amount": 53,
                    "currency": "GBP"
                },
                "destination": {
...

Response Schema

Example response fields are illustrative; inspect the JSON before integrating.

Example response fields

Scan these fields before integrating.

data meta success
JSON Response
200 OK
{
    "data": {
        "fares": [
            {
                "path": "/train-times/london-to-paris",
                "origin": {
                    "name": "London"
                },
                "is_reverse": true,
                "price_from": {
                    "amount": 53,
                    "currency": "GBP"
                },
                "destination": {
                    "name": "Paris"
                },
                "duration_minutes": 148
            },
            {
                "path": "/train-times/paris-to-amsterdam",
                "origin": {
                    "name": "Paris"
                },
                "is_reverse": true,
                "price_from": {
                    "amount": 30.88,
                    "currency": "GBP"
                },
                "destination": {
                    "name": "Amsterdam"
                },
                "duration_minutes": 210
            },
            {
                "path": "/train-times/barcelona-to-madrid",
                "origin": {
                    "name": "Barcelona"
                },
                "is_reverse": true,
                "price_from": {
                    "amount": 16.76,
                    "currency": "GBP"
                },
                "destination": {
                    "name": "Madrid"
                },
                "duration_minutes": 182
            }
        ],
        "fare_count": 3
    },
    "meta": {
        "billable": true,
        "endpoint_family": "fares_best"
    },
    "success": true
}

Errors

Handle these documented responses before retrying or showing customer-facing failures.

503

Upstream Unavailable

Trainline did not answer in time. Scrappa retries on other exits first. This response is not billable. Retry after a few seconds.

{
    "meta": {
        "billable": false,
        "retryable": true,
        "endpoint_family": "fares_best"
    },
    "error": {
        "code": "UPSTREAM_UNAVAILABLE",
        "message": "The Trainline service is temporarily unavailable. Please retry."
    },
    "success": false
}

Generate Code with AI

Copy a ready-made prompt with all the endpoint details, parameters, and example responses. Paste it into ChatGPT, Claude, or any AI assistant to instantly generate working code.

Try It Live

Test this endpoint in our interactive playground with real data.