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

Trainline Nearby Stations API Documentation

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

Trainline Nearby Stations API Documentation List stations that travellers use together with a given station for a weekday time window. The answer has the same shape as the stations endpoint. The window is one of four fixed blocks of the day.

Trainline Nearby Stations API Documentation 1 credit/request

Endpoint

Request preview
GET
https://scrappa.co/api/trainline/stations/nearby
Auth header
x-api-key
Cost
1 credit/request
station_id = 1234567890
Response preview
200 OK
{
    "data": {
        "window": "0600-1200",
        "stations": [
            {
                "id": "urn:trainline:generic:loc:MAN2968gb",
                "name": "Manchester Piccadilly",
                "type": "station",
                "score": 0.291,
                "parent": {
                    "name": "Manchester",
                    "type": "stationGroup"
                },
                "carriers": [
...

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.

station_id string Required

Station id from the stations endpoint. Example: urn:trainline:generic:loc:EUS1444gb.

Example value 1234567890
window string Optional

Weekday time window: 0000-0600, 0600-1200, 1200-1800 or 1800-2400. Defaults to 0600-1200.

Example value example
locale string Optional

Language of the names, e.g. en-GB. 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": {
        "window": "0600-1200",
        "stations": [
            {
                "id": "urn:trainline:generic:loc:MAN2968gb",
                "name": "Manchester Piccadilly",
                "type": "station",
                "score": 0.291,
                "parent": {
                    "name": "Manchester",
                    "type": "stationGroup"
                },
                "carriers": [
                    "atoc",
                    "benerail",
                    "benemoove",
                    "pao_sncf",
                    "nationalexpress"
                ],
                "latitude": 53.4767,
                "subtitle": null,
                "timezone": "Europe/London",
                "longitude": -2.229,
                "attributes": [
                    "MainStation",
                    "BusStation",
                    "category:train"
                ],
                "short_code": "MAN",
                "country_code": "GB"
            },
            {
                "id": "urn:trainline:generic:loc:BHM1127gb",
                "name": "Birmingham New Street",
                "type": "station",
                "score": 0.247,
                "parent": {
                    "name": "Birmingham",
                    "type": "stationGroup"
                },
                "carriers": [
                    "atoc",
                    "benerail",
                    "benemoove",
                    "pao_sncf",
                    "nationalexpress"
                ],
                "latitude": 52.4782,
                "subtitle": "City centre, Main",
                "timezone": "Europe/London",
                "longitude": -1.8984,
                "attributes": [
                    "MainStation",
                    "BusStation",
                    "category:train"
                ],
                "short_code": "BHM",
                "country_code": "GB"
            },
            {
                "id": "urn:trainline:generic:loc:MKC1378gb",
                "name": "Milton Keynes Central",
                "type": "station",
                "score": 0.223,
                "parent": null,
                "carriers": [
                    "atoc",
                    "benerail",
                    "benemoove",
                    "pao_sncf",
                    "nationalexpress"
                ],
                "latitude": 52.0343,
                "subtitle": null,
                "timezone": "Europe/London",
                "longitude": -0.7741,
                "attributes": [
                    "BusStation",
                    "category:train"
                ],
                "short_code": "MKC",
                "country_code": "GB"
            }
        ],
        "station_id": "urn:trainline:generic:loc:EUS1444gb"
    },
    "meta": {
        "billable": true,
        "endpoint_family": "stations_nearby"
    },
    "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_nearby"
    },
    "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.