# Trainline Nearby Stations API Documentation

<p><strong>Trainline Nearby Stations API Documentation</strong> 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.</p>

- **Documentation:** [https://scrappa.co/docs/trainline-api/trainline_stations_nearby](https://scrappa.co/docs/trainline-api/trainline_stations_nearby)
- **API group:** Trainline API
- **Endpoint:** `GET https://scrappa.co/api/trainline/stations/nearby`

## Authentication

Send your Scrappa API key in the `X-API-KEY` request header. Paid endpoints also support accountless x402 payments when called without an API key.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `station_id` | string | Yes | Station id from the stations endpoint. Example: urn:trainline:generic:loc:EUS1444gb. |
| `window` | string | No | Weekday time window: 0000-0600, 0600-1200, 1200-1800 or 1800-2400. Defaults to 0600-1200. |
| `locale` | string | No | Language of the names, e.g. en-GB. Defaults to en-GB. |

## Example response

```json
{
    "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

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A required parameter is missing or invalid. This response is not billable. |
| 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. |

## More Scrappa resources

- [API documentation](https://scrappa.co/docs)
- [Full LLM-readable API reference](https://scrappa.co/llms-full.txt)
- [OpenAPI specification](https://scrappa.co/docs/api.json)
- [Pricing](https://scrappa.co/pricing)
