{
  "openapi": "3.0.1",
  "info": {
    "title": "Trainline Rail Scraper - Journeys, Fares, Stations, Railcards",
    "description": "Trainline Rail Scraper pulls journey departures, daily fare calendars, station matches, UK railcards, train calling points and live service status from Trainline's anonymous mobile API. Six dataset views across four input modes: journeys, fareCalendar, stations and railcards.",
    "version": "0.1",
    "x-build-id": "Y8cf2rAeJ3HOspIL4"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/rl1987~trainline-api-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-rl1987-trainline-api-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/rl1987~trainline-api-scraper/runs": {
      "post": {
        "operationId": "runs-sync-rl1987-trainline-api-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/rl1987~trainline-api-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-rl1987-trainline-api-scraper",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "title": "Scraping mode",
            "enum": [
              "journeys",
              "fareCalendar",
              "stations",
              "railcards"
            ],
            "type": "string",
            "description": "What to scrape. journeys = every departure on one route for one travel day, each row one departure with both fare classes. fareCalendar = the cheapest fare across a range, one row per travel day. stations = station/place lookup. railcards = the UK railcard catalogue.",
            "default": "journeys"
          },
          "origin": {
            "title": "Origin",
            "type": "string",
            "description": "Journeys and fare calendar modes. Where the trip starts: a station or city name such as \"London Euston\" or \"Manchester Piccadilly\", or a Trainline location id (urn:trainline:generic:loc:...). The name is resolved against Trainline's own station list first; a name that does not really match stops the run with an explanation instead of guessing, because the lookup ranks its answers rather than filtering them. Prefilled with a real GB route so the default run returns rows; change it for your own route."
          },
          "destination": {
            "title": "Destination",
            "type": "string",
            "description": "Journeys and fare calendar modes. Where the trip ends, in the same form as the origin. Prefilled with a real GB route so the default run returns rows; change it for your own route."
          },
          "departureDate": {
            "title": "Departure date",
            "type": "string",
            "description": "Journeys mode. The travel day to list journeys for, as YYYY-MM-DD. Trainline publishes timetables roughly a year ahead; a day beyond that comes back empty rather than erroring. Leave it empty and the Actor searches today + 7 days. The input carries no fixed default date on purpose - a literal date is right on the day it is written and a past date afterwards. Every substitution is named in the run's status message."
          },
          "returnDate": {
            "title": "Return date",
            "type": "string",
            "description": "Journeys mode, optional. Set it and the return direction is scraped as well, so one run gives both legs. Leave it empty for a single direction."
          },
          "fromDate": {
            "title": "Calendar start date",
            "type": "string",
            "description": "Fare calendar mode. First travel day of the range, as YYYY-MM-DD. The range is fetched in windows of up to 31 days, one request each. Leave it empty and the Actor searches today + 7 days. The input carries no fixed default date on purpose - a literal date is right on the day it is written and a past date afterwards. Every substitution is named in the run's status message."
          },
          "toDate": {
            "title": "Calendar end date",
            "type": "string",
            "description": "Fare calendar mode. Last travel day of the range, inclusive, as YYYY-MM-DD. At most 366 days after the start day. Leave it empty and the Actor covers 14 days from the start day. The input carries no fixed default date on purpose. Every substitution is named in the run's status message."
          },
          "stationQueries": {
            "title": "Station queries",
            "type": "array",
            "description": "Stations mode. One entry per name to look up: a station, a city or any place Trainline knows, e.g. \"Leeds\" or \"Bristol Temple Meads\". Each entry returns only the places that genuinely match it, so a misspelled name returns nothing rather than a loosely similar station.",
            "items": {
              "type": "string"
            }
          },
          "includeRailcardTerms": {
            "title": "Include railcard terms",
            "type": "boolean",
            "description": "Railcards mode. Also fetch each card's terms and conditions summary and description, one extra request per card. Billed as an extra railcard-terms event per enriched card; leave it off to get the catalogue only.",
            "default": false
          },
          "includeCallingPoints": {
            "title": "Include calling points and live status",
            "type": "boolean",
            "description": "Journeys and fareCalendar modes. Also fetch every stop each train calls at, with scheduled and real-time times, platforms and live running status - one request per distinct train, billed per calling-point row plus a service-status row for the train itself. Off by default: a day of London to Manchester is about 63 journeys but only 10-20 distinct trains.",
            "default": false
          },
          "maxServicesPerSearch": {
            "title": "Max trains to enrich",
            "minimum": 0,
            "maximum": 200,
            "type": "integer",
            "description": "Journeys and fareCalendar modes, when calling points are on. How many distinct trains each search may look up, so a long fare calendar cannot turn into hundreds of extra requests. 0 means no limit. The trains are taken in the order the API returns them, so the earliest departures are enriched first.",
            "default": 10
          },
          "currency": {
            "title": "Currency",
            "enum": [
              "AED",
              "ARS",
              "AUD",
              "BRL",
              "CAD",
              "CHF",
              "CLP",
              "CNY",
              "COP",
              "DKK",
              "EUR",
              "GBP",
              "HKD",
              "IDR",
              "ILS",
              "INR",
              "JPY",
              "KRW",
              "MXN",
              "MYR",
              "NOK",
              "NZD",
              "PLN",
              "SAR",
              "SEK",
              "SGD",
              "THB",
              "TRY",
              "USD",
              "ZAR"
            ],
            "type": "string",
            "description": "Journeys and fare calendar modes. The currency the fares are priced in. This is the app's own enabled-currency list (30 codes, from its setup call), and the API answers a fare in it directly - GBP, EUR and USD were all confirmed to come back with that currencyCode. A route outside the UK priced in GBP is a converted price.",
            "default": "GBP"
          },
          "locale": {
            "title": "Locale",
            "enum": [
              "en-GB",
              "en-US",
              "de-DE",
              "de-AT",
              "de-CH",
              "fr-FR",
              "fr-CH",
              "it-IT",
              "it-CH",
              "es-ES",
              "nb-NO",
              "sv-SE",
              "da-DK",
              "nl-NL",
              "pt-BR",
              "pt-PT"
            ],
            "type": "string",
            "description": "Language/region for station names and place search. This is the language set Trainline's own site publishes (16), and the place search really does localise: the API requires the locale on every place search - without it the search answers HTTP 400 - so a value is always sent.",
            "default": "en-GB"
          },
          "maxItems": {
            "title": "Maximum rows",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many delivered rows and bill nothing further. 0 means no limit. Each delivered row costs one billing event (the bulk ones: a single day of London Euston to Manchester Piccadilly is about 63 journey rows, a 30-day fare calendar about 30 rows).",
            "default": 0
          },
          "maxConcurrency": {
            "title": "Max concurrency",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "How many requests run at once. The API answers fine at 5; raise it for a long fare calendar and lower it if you start seeing 429s.",
            "default": 5
          },
          "maxRequestsPerCrawl": {
            "title": "Max requests",
            "minimum": 0,
            "type": "integer",
            "description": "Hard cap on the number of requests this run may make, a budget guard on top of maxItems. 0 means no cap.",
            "default": 0
          },
          "maxRequestRetries": {
            "title": "Max request retries",
            "minimum": 0,
            "maximum": 20,
            "type": "integer",
            "description": "How many times a failing request is retried before it is recorded in the failed-requests dataset. Blocked and rate-limited responses are retried with a new session; a validation error or a schema change is not retried at all.",
            "default": 5
          },
          "maxSessionRotations": {
            "title": "Max session rotations",
            "minimum": 0,
            "maximum": 50,
            "type": "integer",
            "description": "How many times a session may be replaced after being blocked before the request is given up on.",
            "default": 10
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Apify proxy to use. The API answered 200 from this host's own egress during the reverse-engineering probes (with an intermittent DataDome challenge on the calling-points endpoint), so residential proxies are optional rather than required. Leave it empty to run without a proxy."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}