APIs / Travel / Trainline

1 credit per call15 endpoints9 datapointsChecked working 6 Dec 2026

Trainline API

Trainline API for stations, journey search, fare calendars, ticket options, calling points and cards as JSON. 15 endpoints, 1 credit per successful call.

Trainline
GET/v1/trainline/cards
{
  "success": true,
  "data": {
    "card_count": 42,
    "cards": [
      {
        "code": "urn:trainline:atoc:card:TSU",
        "name": "16-17 Saver",
        "description": "16-17 Saver",
        "language": "en",
        "carriers": [
          "atoc"
        ],
        "requires_number": false,
        "has_expiration_date": false,
        "is_loyalty_card": false,
        "business_only": false
      },
      {
        "code": "urn:trainline:atoc:card:YNG",
        "name": "16-25 Railcard",
        "description": "16-25 Railcard",
        "language": "en",
        "carriers": [
          "atoc"
        ],
        "requires_number": false,
        "has_expiration_date": false,
        "is_loyalty_card": false,
        "business_only": false
      },
      {
        "code": "urn:trainline:atoc:card:W18",
        "name": "18 Saver - Transport for Wales",
        "description": "18 Saver - Transport for Wales",
        "language": "en",
        "carriers": [
          "atoc"
        ],
        "requires_number": false,
        "has_expiration_date": false,
        "is_loyalty_card": false,
        "business_only": false
      }
    ]
  },
  "meta": {
    "endpoint_family": "cards"
  }
}
200 OKJSONX-Credits-Used: 1
Recorded 12 Nov 2026 and shortened.

Sample data

What one call returns

A recorded run of cards: the fields and shapes you will get, shortened to 3 items.

#codestringnamestringdescriptionstringlanguagestringcarriersstring[]requires_numberbooleanhas_expiration_datebooleanis_loyalty_cardbooleanbusiness_onlyboolean
1urn:trainline:atoc:card:TSU16-17 Saver16-17 Saveren[1 item]falsefalsefalsefalse
2urn:trainline:atoc:card:YNG16-25 Railcard16-25 Railcarden[1 item]falsefalsefalsefalse
3urn:trainline:atoc:card:W1818 Saver - Transport for Wales18 Saver - Transport for Walesen[1 item]falsefalsefalsefalse

Recorded 12 Nov 2026 · 3 items shown · 9 datapoints per itemGET /v1/trainline/cards

9 datapoints

Identity

  • namestring

Other

  • codestring
  • descriptionstring
  • languagestring
  • carriersstring[]
  • requires_numberboolean
  • has_expiration_dateboolean
  • is_loyalty_cardboolean
  • business_onlyboolean

Playground

Run this API

cURLshell
curl "https://api.perceptlayer.com/v1/trainline/cards" \
  -H "X-API-Key: $API_KEY"

Trainline · 15 endpoints

Endpoints

Every endpoint takes the same key. Open one for its parameters, the fields it returns and an example request.

EndpointRequired parametersReturnsCost
GET/v1/trainline/cards
none
codenamedescriptionlanguagecarriersrequires_number+3 more
1 credit
GET/v1/trainline/cards-discounts
none
codenamedescriptionshort_namegrouplanguage+6 more
1 credit
GET/v1/trainline/fares-best
none
origindestinationprice_fromduration_minutesis_reversepath
1 credit
GET/v1/trainline/fares-calendar
origindestinationdate_fromdate_to+1 optional
origindestinationdate_fromdate_tocurrencydays
1 credit
GET/v1/trainline/fares-calendar-return
origindestinationdate_fromdate_toreturn_fromreturn_to+1 optional
origindestinationdate_fromdate_tocurrencyreturn_from+2 more
1 credit
GET/v1/trainline/fares-calendar-times
origindestinationdate_fromdate_to+1 optional
origindestinationdate_fromdate_tocurrencydays
1 credit
GET/v1/trainline/journeys
origindestinationdate+9 optional
origindestinationjourney_typecurrencytransport_modesearch_id+4 more
1 credit
GET/v1/trainline/journeys-calling-points
timetable_idcarrierdeparture_timeorigindestination
carriertimetable_idservice_datetransport_modecancelledhas_live_status+1 more
1 credit
GET/v1/trainline/journeys-local-transport
search_id+2 optional
search_idcurrencyalternatives
1 credit
GET/v1/trainline/journeys-page
search_id+4 optional
previous_search_iddirectioncurrencytransport_modesearch_idexpires_at+3 more
1 credit
GET/v1/trainline/journeys-price-prediction
search_idjourney_id+1 optional
search_idjourney_id
1 credit
GET/v1/trainline/journeys-return
search_idjourney_id+3 optional
outward_search_idoutward_journey_idcurrencytransport_modesearch_idexpires_at+3 more
1 credit
GET/v1/trainline/journeys-ticket-options
search_idoutward_journey_id+2 optional
search_idcurrencyticket_optionsticket_classes
1 credit
GET/v1/trainline/stations
query+2 optional
idnameshort_codetypecountry_codetimezone+7 more
1 credit
GET/v1/trainline/stations-nearby
station_id+2 optional
station_idwindowstations
1 credit

Overview

About the Trainline API

What you can get

The Trainline API returns Trainline rail and coach data as JSON through 15 endpoints. Most of them accept currency (GBP or EUR).

  • Stations: stations takes a query, with limit and locale; stations-nearby takes a station_id, with window (0000-0600, 0600-1200, 1200-1800 or 1800-2400) and locale.
  • Journey search: journeys takes an origin, destination and date, with time, journey_type (single, return or open_return), return_date, return_time, adults, children, child_age and transport_mode (all, train or coach).
  • Journey details: journeys-page, journeys-return, journeys-ticket-options, journeys-price-prediction and journeys-local-transport take a search_id. journeys-return and journeys-price-prediction also take a journey_id, and journeys-ticket-options an outward_journey_id (with an optional inward_journey_id). journeys-calling-points takes a timetable_id, carrier, departure_time, origin and destination.
  • Fare calendars: fares-calendar and fares-calendar-times take an origin, destination, date_from and date_to; fares-calendar-return adds return_from and return_to. fares-best takes no parameters.
  • Cards: cards and cards-discounts take no parameters.

How a call works

Scan return fares over a range of dates: GET /v1/trainline/fares-calendar-return?origin=urn:trainline:generic:loc:182gb&destination=urn:trainline:generic:loc:115gb&date_from=2027-01-04&date_to=2027-01-06&return_from=2027-01-07&return_to=2027-01-09 with your key in the X-API-Key header. The journey-detail endpoints take a search_id and journey IDs rather than stations and dates. journeys-page moves through a search with page (next or previous) and direction (outward or inward). Every successful call costs 1 credit; failed calls cost nothing.

TravelJSONRESTMCP

More travel APIs

Use cases

Watch single and return fares on a route across a range of dates

Use the Trainline API to watch single and return fares on a route across a range of dates

Compare train and coach options on a route with `transport_mode`

Use the Trainline API to compare train and coach options on a route with `transport_mode`

Look up stations by name for a travel planner or booking tool

Use the Trainline API to look up stations by name for a travel planner or booking tool

List the calling points of a chosen service

Use the Trainline API to list the calling points of a chosen service

FAQ

Questions

Do I need a Trainline API key?

No. You call this Trainline API with your Perceptlayer key in the `X-API-Key` header, with no Trainline login.

How much does the Trainline API cost?

Each successful call costs one credit. New accounts get free credits to start, and credit packs bring the price down as you scale.

What format are responses in?

Every endpoint returns JSON, with no HTML parsing on your side.

Can I search coach journeys too?

Yes. `journeys`, `journeys-page` and `journeys-return` take `transport_mode`, set to all, train or coach.

Is this the official Trainline API?

No. Perceptlayer is an independent service and is not affiliated with Trainline. It returns Trainline data as JSON with a Perceptlayer key, so there is no Trainline developer account, app review or partner approval to get first. It only reads data: if Trainline has an official API and you need to act on your own Trainline account, such as posting, managing orders or reading private data, use that one.

Should I build a Trainline scraper instead?

You can, but a Trainline scraper is code you maintain: page changes break it, requests get blocked, and Trainline's terms govern how you collect data. The Trainline API gives you 15 endpoints of named JSON fields for 1 credit per successful call, and failed calls cost nothing. A scraper makes sense only for data these endpoints don't return, so check the response in the playground on this page first.

Try the Trainline API with 100 free credits

No credit card. Failed calls are never billed.