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

Trainline Stations API Documentation

GET https://scrappa.co/api/trainline/stations

Trainline Stations API Documentation Find rail and coach stations, cities and station groups by name, city or station code. Each result has a station id, a type (station or station group), the country, coordinates, the time zone and the carriers that serve it. Use the id as origin or destination in the journey and fare endpoints. Always take station ids from this endpoint: an id typed by hand can return no journeys.

Trainline Stations API Documentation 1 credit/request

Endpoint

Request preview
GET
https://scrappa.co/api/trainline/stations
Auth header
x-api-key
Cost
1 credit/request
query = coffee shops
Response preview
200 OK
{
    "data": {
        "query": "london",
        "locale": "en-GB",
        "stations": [
            {
                "id": "urn:trainline:generic:loc:182gb",
                "name": "London",
                "type": "stationGroup",
                "score": 1,
                "parent": null,
                "carriers": [
                    "atoc",
                    "benerail",
...

Parameters

Start with the required fields, then add optional filters only when your use case needs them.

Runnable path

1 required parameter needed before sending a request.

2 optional filters available.

query string Required

Station, city or code, 2 to 100 characters. Example: london.

Example value coffee shops
limit integer Optional

Number of results, 1 to 30. Defaults to 10.

Example value 10
locale string Optional

Language of the names, e.g. en-GB or de-DE. Defaults to en-GB.

Example value en-US

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": {
        "query": "london",
        "locale": "en-GB",
        "stations": [
            {
                "id": "urn:trainline:generic:loc:182gb",
                "name": "London",
                "type": "stationGroup",
                "score": 1,
                "parent": null,
                "carriers": [
                    "atoc",
                    "benerail",
                    "benemoove",
                    "distribusion",
                    "pao_sncf",
                    "nationalexpress",
                    "eurostardirect"
                ],
                "latitude": null,
                "subtitle": "Any",
                "timezone": "Europe/London",
                "longitude": null,
                "attributes": [
                    "BusStation",
                    "category:point"
                ],
                "short_code": "182",
                "country_code": "GB"
            },
            {
                "id": "urn:trainline:generic:loc:EUS1444gb",
                "name": "London Euston",
                "type": "station",
                "score": 0.42039064,
                "parent": {
                    "name": "London",
                    "type": "stationGroup"
                },
                "carriers": [
                    "atoc",
                    "benerail",
                    "benemoove",
                    "pao_sncf",
                    "nationalexpress"
                ],
                "latitude": 51.5284,
                "subtitle": null,
                "timezone": "Europe/London",
                "longitude": -0.1346,
                "attributes": [
                    "BusStation",
                    "category:train"
                ],
                "short_code": "EUS",
                "country_code": "GB"
            }
        ]
    },
    "meta": {
        "billable": true,
        "endpoint_family": "stations"
    },
    "success": true
}

Errors

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

422

Validation Error

A required parameter is missing or invalid. This response is not billable.

{
    "errors": {
        "origin": [
            "The origin is a station id from the stations endpoint."
        ]
    },
    "message": "The request validation failed"
}
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": "stations"
    },
    "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.