{
  "openapi": "3.0.1",
  "info": {
    "title": "Trenitalia Timetable Scraper - Solutions, Fares & Status",
    "description": "Collect Trenitalia journey solutions and fares with seats left, live train status with stops, station boards and station ids as flat JSON. Four modes, six dataset views, scrapedAt and provenance on every row; no login or API key.",
    "version": "0.1",
    "x-build-id": "IHv7IvfOTbU2Xq6pd"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/rl1987~trenitalia-timetable-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-rl1987-trenitalia-timetable-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~trenitalia-timetable-scraper/runs": {
      "post": {
        "operationId": "runs-sync-rl1987-trenitalia-timetable-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~trenitalia-timetable-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-rl1987-trenitalia-timetable-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",
        "properties": {
          "mode": {
            "title": "What to collect",
            "enum": [
              "search",
              "trainStatus",
              "stationBoard",
              "stations"
            ],
            "type": "string",
            "description": "Which of the four modes to run. Search resolves two station names and returns the journeys between them with fares and seats left; Train status follows a train number's current run and stops; Station board reads a station's departures or arrivals board; Stations returns station ids for a name.",
            "default": "search"
          },
          "origin": {
            "title": "From station",
            "type": "string",
            "description": "Departure station NAME, e.g. 'Milano Centrale'. Resolved against Trenitalia's own station list; an exact name wins, otherwise the first non-city match. A name that matches nothing stops the run instead of guessing a station id."
          },
          "destination": {
            "title": "To station",
            "type": "string",
            "description": "Arrival station NAME, e.g. 'Roma Termini'. Must differ from the origin."
          },
          "departureDate": {
            "title": "Departure date",
            "type": "string",
            "description": "Date of travel (YYYY-MM-DD). Timetables are published months ahead, but a date far in the past returns nothing."
          },
          "departureTime": {
            "title": "Departure time",
            "type": "string",
            "description": "Earliest departure time to search from, 24-hour HH:MM (default 08:00). This is a time of day, not a date, so it is typed rather than picked.",
            "default": "08:00"
          },
          "adults": {
            "title": "Adults",
            "minimum": 1,
            "maximum": 9,
            "type": "integer",
            "description": "Number of adult passengers. Sent as the API's `adults`; it does not change which journeys are listed, only the price context the upstream quotes.",
            "default": 1
          },
          "children": {
            "title": "Children",
            "minimum": 0,
            "maximum": 9,
            "type": "integer",
            "description": "Number of child passengers (0-9). Sent as the API's `children`.",
            "default": 0
          },
          "service": {
            "title": "Service type",
            "enum": [
              "all",
              "frecce",
              "intercity",
              "regional"
            ],
            "type": "string",
            "description": "Filter the journeys by service family: all, Frecce (high speed), Intercity or Regional. Maps to the API's `criteria.selectedTypeTrips`.",
            "default": "all"
          },
          "order": {
            "title": "Sort order",
            "enum": [
              "departure",
              "arrival",
              "fastest",
              "cheapest"
            ],
            "type": "string",
            "description": "How the API sorts the journeys: by departure, by arrival, fastest or cheapest. Maps to `criteria.order`.",
            "default": "departure"
          },
          "maxSolutions": {
            "title": "Max journeys for the day",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "How many journey options to collect for the day, 1-100. The API serves only a forward window of ~10 journeys from departureTime, so the Actor walks successive time windows (each ≤20, the upstream per-request cap) until it has this many or the day ends. One row per journey, plus one per fare when includeFares is on.",
            "default": 5
          },
          "includeFares": {
            "title": "Include fares and seats left",
            "type": "boolean",
            "description": "Fetch the fare rows too (travel class, fare family, refund/change flags, seats left). ON BY DEFAULT AND BILLED SEPARATELY: every fare is its own charged row, so a 5-journey search with 2 fares each bills 5 solution rows plus 10 fare rows. Turn it off when you only need the timetable.",
            "default": true
          },
          "trainNumbers": {
            "title": "Train numbers",
            "type": "array",
            "description": "One or more train numbers to follow, e.g. 9611. Each number resolves to its current run(s) and each run produces one trainStatus row plus one stop row per stop. Up to 25 numbers per run.",
            "items": {
              "type": "string"
            }
          },
          "boardStation": {
            "title": "Board station",
            "type": "string",
            "description": "Station NAME whose board to read, e.g. 'Milano Centrale'. Resolved against Trenitalia's station list; a name that matches nothing queues no board."
          },
          "boardDirection": {
            "title": "Board direction",
            "enum": [
              "departures",
              "arrivals"
            ],
            "type": "string",
            "description": "Departures or arrivals for that station. On an arrivals board the row's `origin` is where the train came from and `destination` is the board station.",
            "default": "departures"
          },
          "stationQuery": {
            "title": "Station name (any part)",
            "type": "string",
            "description": "Text to match against Trenitalia's station list, e.g. 'Milano' or 'Termini'. The match is a substring filter, so a name that does not exist returns no rows rather than a page of near misses. Use this mode to find the exact name another mode needs."
          },
          "maxItems": {
            "title": "Max rows",
            "minimum": 0,
            "type": "integer",
            "description": "Stop after this many rows have been DELIVERED (0 = no limit). Counted by the billing ledger after de-duplication and across ALL row kinds of the run, so it is a limit on what you receive and pay for, not on what the target returned.",
            "default": 0
          },
          "maxConcurrency": {
            "title": "Max concurrency",
            "minimum": 1,
            "type": "integer",
            "description": "Max number of requests processed in parallel.",
            "default": 5
          },
          "maxRequestsPerCrawl": {
            "title": "Max requests per run",
            "minimum": 0,
            "type": "integer",
            "description": "Safety cap on total requests. 0 = unlimited.",
            "default": 0
          },
          "maxRequestRetries": {
            "title": "Max request retries",
            "minimum": 0,
            "type": "integer",
            "description": "Retries per request before it's marked failed. Does NOT bound retries caused by a blocked/rate-limited status code (401/403/429 by default) - see maxSessionRotations for that.",
            "default": 5
          },
          "maxSessionRotations": {
            "title": "Max session rotations",
            "minimum": 0,
            "type": "integer",
            "description": "Retries for a blocked/rate-limited status code (401/403/429 by default - see src/errors.py), each with a fresh session/proxy and a fresh CustomerDeviceId. Separate budget from maxRequestRetries.",
            "default": 10
          },
          "proxyConfiguration": {
            "title": "Proxy configuration",
            "type": "object",
            "description": "Apify Proxy or your own proxies. The target answered from a datacenter IP when measured on 2026-11-19, so residential is not required; switch it on if a run starts seeing 403s.",
            "default": {
              "useApifyProxy": true
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}