Railway Stations

Autocomplete UK railway stations by prefix. Returns the station code, coordinates, and locality.

Try it

Endpoint

GET/v1/railway-station/<query>
Base URL: https://autocomplete.namedone.com

SDK Usage

railwayStations()
1import { createClient } from "@namedone/autocomplete"
2
3const nd = createClient("nd_...")
4const { results } = await nd.railwayStations("london")

curl

1# Exchange your API key for a token
2curl -X POST https://token.namedone.com/v1 \
3 -H "Content-Type: application/json" \
4 -d '{"apiKey":"nd_..."}'
5
6# Query the railway stations endpoint
7curl "https://autocomplete.namedone.com/v1/railway-station/london?token=<jwt>"

Response Format

JSON
{
"results": [
{
"id": "railway-station-0",
"text": "London King's Cross",
"subtitle": "London",
"type": "railway-station"
"data": {
"code": <string>,
"lat": <number>,
"lng": <number>,
"locality": <string>
}
}
],
"query": "london"
}

Data Fields

FieldTypeDescription
codestringStation CRS code (e.g. "KGX")
latnumberWGS84 latitude
lngnumberWGS84 longitude
localitystringTown or city

API Query Parameters

Sent as query string parameters on the HTTP request to the API.

ParameterTypeDefaultDescription
tokenstringJWT obtained from the token API. Required for authentication.

SDK Options

Passed to the SDK methods (e.g. firstNames(query, opts)). These are processed client-side and never sent to the API.

OptionTypeDefaultDescription
limitnumber10Maximum number of results (1–50). Applied client-side by the SDK.
simplebooleanfalseSimplify response: deduplicate by text and strip to {text, type}.
sortByProximityarraySort results by proximity to coordinates. Client-side only.

Examples

Query: london

{
"results": [
{
"id": "railway-station-0",
"text": "London King's Cross",
"subtitle": "London",
"type": "railway-station",
"data": {
"code": "KGX"
}
},
{
"id": "railway-station-1",
"text": "London Paddington",
"subtitle": "London",
"type": "railway-station",
"data": {
"code": "PAD"
}
},
{
"id": "railway-station-2",
"text": "London Victoria",
"subtitle": "London",
"type": "railway-station",
"data": {
"code": "VIC"
}
}
],
"query": "london"
}

Notes

  • Data is sourced from NaPTAN (National Public Transport Access Nodes).
  • Source: Department for Transport, OGL v3.0.