{
  "openapi": "3.0.1",
  "info": {
    "title": "Spain Train Fares Scraper – Renfe, Avlo & Ouigo Prices",
    "description": "Extract Renfe (AVE, Avlo, Alvia) and Ouigo train fares in Spain for any date range: departure, arrival, cheapest price, sold-out flag and booking link, plus the cheapest train of each day. Type city names, no station codes. $1 per 1,000 trains.",
    "version": "1.0",
    "x-build-id": "edAsgs9LhUyW9gDfq"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/phantom-x64~spain-train-fares-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-phantom-x64-spain-train-fares-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/phantom-x64~spain-train-fares-scraper/runs": {
      "post": {
        "operationId": "runs-sync-phantom-x64-spain-train-fares-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/phantom-x64~spain-train-fares-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-phantom-x64-spain-train-fares-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": {
          "routes": {
            "title": "Routes",
            "type": "array",
            "description": "One route per line, written as 'Origin -> Destination' with city names, e.g. 'Madrid -> Barcelona', 'Valencia -> Madrid', 'Sevilla -> Madrid'. Accents and case do not matter. Supported cities: Madrid, Barcelona, Valencia, Alicante, Sevilla, Málaga, Córdoba, Zaragoza, Tarragona, Albacete, Cuenca, Segovia, Valladolid, Murcia, Elche (Renfe + Ouigo) and Lleida, Girona, Figueres, Ciudad Real, Puertollano, Toledo, Guadalajara, Calatayud, Huesca, Castellón, Villena, Orihuela, Granada, Antequera, Jaén, Almería, Cádiz, Jerez, Huelva, Salamanca, Palencia, León, Zamora, Burgos, Ourense, Santiago, A Coruña, Vigo, Oviedo, Gijón, Santander, Bilbao, Vitoria, San Sebastián, Pamplona, Logroño, Badajoz, Mérida, Cáceres, Plasencia (Renfe only). Cities with several stations (Madrid, Barcelona, Valencia, Zaragoza...) search all of them. Max 20 routes per run.",
            "default": [
              "Madrid -> Barcelona"
            ],
            "items": {
              "type": "string"
            }
          },
          "includeReturn": {
            "title": "Also search the return direction",
            "type": "boolean",
            "description": "Also search every route the other way round (Barcelona -> Madrid for 'Madrid -> Barcelona'), for the same dates.",
            "default": false
          },
          "startDate": {
            "title": "First travel date",
            "type": "string",
            "description": "First departure date to search, format YYYY-MM-DD (Spanish time). Leave empty to start today. Past dates are moved to today."
          },
          "days": {
            "title": "Number of days",
            "minimum": 1,
            "maximum": 60,
            "type": "integer",
            "description": "How many consecutive travel days to search, starting at the first travel date (1-60). Each extra day adds about 5-25 seconds per route (Renfe answers slowly to cloud servers); the default of 7 days takes about 3 minutes (the pre-filled 1 day takes about 30 seconds).",
            "default": 7
          },
          "endDate": {
            "title": "Last travel date (optional)",
            "type": "string",
            "description": "Optional last departure date, format YYYY-MM-DD. If set, it replaces 'Number of days'. The range is capped at 60 days."
          },
          "operators": {
            "title": "Operators",
            "type": "array",
            "description": "Which operators to search. Renfe includes AVE, Avlo (Renfe's low-cost brand), Alvia, Avant, Intercity and regional trains. Ouigo is the low-cost French operator (Madrid, Barcelona, Valencia, Alicante, Andalusia, Murcia, Valladolid/Segovia lines). Iryo is not supported.",
            "items": {
              "type": "string",
              "enum": [
                "renfe",
                "ouigo"
              ],
              "enumTitles": [
                "Renfe (AVE, Avlo, Alvia, Avant...)",
                "Ouigo"
              ]
            },
            "default": [
              "renfe",
              "ouigo"
            ]
          },
          "maxPrice": {
            "title": "Max price (EUR)",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Keep only trains whose cheapest fare is at or below this price in euros (1 adult). Sold-out trains are then left out. Leave empty for no price limit."
          },
          "directOnly": {
            "title": "Direct trains only",
            "type": "boolean",
            "description": "Leave out connections with a change of train (Renfe sometimes offers e.g. Avant + AVE combinations).",
            "default": false
          },
          "includeSoldOut": {
            "title": "Include sold-out trains",
            "type": "boolean",
            "description": "Also output trains with no fare on sale (soldOut = true, price = null). Ignored when a max price is set.",
            "default": true
          },
          "output": {
            "title": "Output",
            "enum": [
              "trainsAndCheapest",
              "trains",
              "cheapestOnly"
            ],
            "type": "string",
            "description": "<b>trainsAndCheapest</b>: one row per train and day plus one 'cheapest of the day' row per route and day. <b>trains</b>: only the train rows. <b>cheapestOnly</b>: only one row per route and day with the cheapest train (fewest results, lowest cost).",
            "default": "trainsAndCheapest"
          },
          "maxItems": {
            "title": "Max results",
            "minimum": 1,
            "maximum": 100000,
            "type": "integer",
            "description": "Stop after saving (and paying for) this many rows in the whole run, counting train rows and cheapest-per-day rows.",
            "default": 2000
          },
          "proxyConfiguration": {
            "title": "Proxy",
            "type": "object",
            "description": "Optional. By default no proxy is used. If Renfe or Ouigo start refusing requests from Apify servers, select Apify Proxy (residential, country Spain) here.",
            "default": {
              "useApifyProxy": false
            }
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}