# Trainline Stations API Documentation

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

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

## 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 |
| --- | --- | --- | --- |
| `query` | string | Yes | Station, city or code, 2 to 100 characters. Example: london. |
| `limit` | integer | No | Number of results, 1 to 30. Defaults to 10. |
| `locale` | string | No | Language of the names, e.g. en-GB or de-DE. Defaults to en-GB. |

## Example response

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

| 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)
