{
  "openapi": "3.0.1",
  "info": {
    "title": "SJ Train Tickets & Connections Scraper",
    "description": "Scrape live SJ train connections, schedules, ticket prices, transfers, delays, and fares across Sweden and Europe. Extract structured SJ timetable data for travel apps, price monitoring, analytics, and AI agents.",
    "version": "0.0",
    "x-build-id": "hPKnF0g98gHCAm3nq"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/jindrich.bar~sj-ticket-scraper/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-jindrich.bar-sj-ticket-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/jindrich.bar~sj-ticket-scraper/runs": {
      "post": {
        "operationId": "runs-sync-jindrich.bar-sj-ticket-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/jindrich.bar~sj-ticket-scraper/run-sync": {
      "post": {
        "operationId": "run-sync-jindrich.bar-sj-ticket-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": [
          "from",
          "to"
        ],
        "properties": {
          "from": {
            "title": "From station",
            "type": "string",
            "description": "Origin station name or UIC code (e.g. \"Stockholm Central\", \"740000001\"). City names such as \"Stockholm\" or \"Göteborg\" search every station in that city.",
            "default": "Stockholm Central"
          },
          "to": {
            "title": "To station",
            "type": "string",
            "description": "Destination station name or UIC code (e.g. \"Göteborg Central\", \"Malmö C\").",
            "default": "Göteborg"
          },
          "date": {
            "title": "Travel date",
            "type": "string",
            "description": "Travel date (YYYY-MM-DD), Swedish local time. Leave empty to use today. SJ sells tickets up to 365 days ahead."
          },
          "time": {
            "title": "Travel time",
            "pattern": "^\\d{1,2}:\\d{2}$",
            "type": "string",
            "description": "Time in HH:MM (24h) format, Swedish local time. Leave empty to get every departure of the day."
          },
          "timeType": {
            "title": "Time type",
            "enum": [
              "DEPART",
              "ARRIVE"
            ],
            "type": "string",
            "description": "Whether the travel time is the earliest departure or the latest acceptable arrival.",
            "default": "DEPART"
          },
          "adults": {
            "title": "Adults",
            "minimum": 0,
            "maximum": 9,
            "type": "integer",
            "description": "Number of adult passengers (26+) used for ticket pricing.",
            "default": 1
          },
          "childrenAges": {
            "title": "Children / youth ages",
            "type": "array",
            "description": "One entry per child or youth passenger (0–25), giving their age. SJ prices these tickets by age, so the age is required — e.g. [4, 12] books one 4-year-old and one 12-year-old. Max 5 per booking.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "studentAges": {
            "title": "Student ages",
            "type": "array",
            "description": "One entry per student passenger (15+), giving their age. Student tickets need a valid student ID when travelling.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "seniorAges": {
            "title": "Senior ages",
            "type": "array",
            "description": "One entry per senior passenger (18+), giving their age. SJ applies its senior discount from age 65.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "onlyDirectJourneys": {
            "title": "Direct trains only",
            "type": "boolean",
            "description": "If enabled, only journeys without a change of train are returned.",
            "default": false
          },
          "maxTransfers": {
            "title": "Max changes",
            "minimum": 0,
            "maximum": 10,
            "type": "integer",
            "description": "Drop journeys with more than this many changes. Leave empty for no limit. Applied by the actor after the search, so it never suppresses a direct alternative."
          },
          "minTransferTime": {
            "title": "Minimum transfer time",
            "enum": [
              "TEN_MINUTES",
              "TWENTY_MINUTES",
              "THIRTY_MINUTES",
              "FORTY_MINUTES",
              "FIFTY_MINUTES",
              "SIXTY_MINUTES"
            ],
            "type": "string",
            "description": "Require at least this much time at every change. Only these values are accepted by the API."
          },
          "viaStations": {
            "title": "Via stations",
            "type": "array",
            "description": "Station names or UIC codes the journey must pass through (e.g. [\"Hallsberg station\"]).",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "allowedServiceTypes": {
            "title": "Allowed service types",
            "type": "array",
            "description": "Restrict the search to these services. SJ_HIGH = SJ Snabbtåg, SJ_IC = InterCity, SJ_REG = SJ Regional, SJ_NT = night train, X_TRAINOPS = other train operators, X_PTA = regional public transport, X_EXPBUS = express bus. Leave empty for all.",
            "items": {
              "type": "string",
              "enum": [
                "SJ_HIGH",
                "SJ_IC",
                "SJ_REG",
                "SJ_NT",
                "X_TRAINOPS",
                "X_PTA",
                "X_EXPBUS"
              ]
            },
            "default": []
          },
          "excludedServiceTypes": {
            "title": "Excluded service types",
            "type": "array",
            "description": "Exclude these services from the search — e.g. X_EXPBUS to keep replacement and express buses out of the results.",
            "items": {
              "type": "string",
              "enum": [
                "SJ_HIGH",
                "SJ_IC",
                "SJ_REG",
                "SJ_NT",
                "X_TRAINOPS",
                "X_PTA",
                "X_EXPBUS"
              ]
            },
            "default": []
          },
          "includePrices": {
            "title": "Include prices",
            "type": "boolean",
            "description": "Fetch ticket prices for every departure. Disable for a pure timetable scrape — that needs a single request for the whole day instead of one per departure.",
            "default": true
          },
          "includeAllOffers": {
            "title": "Include all tickets",
            "type": "boolean",
            "description": "If enabled, every ticket on offer (each comfort class × flexibility tier) is stored in the \"offers\" field, not just the cheapest ones.",
            "default": false
          },
          "includeServiceDetails": {
            "title": "Include on-board amenities",
            "type": "boolean",
            "description": "If enabled, each leg lists its on-board amenities (wifi, bistro, quiet coach, accessibility) in \"amenities\".",
            "default": false
          },
          "maxResults": {
            "title": "Max results",
            "minimum": 1,
            "maximum": 200,
            "type": "integer",
            "description": "Maximum number of departures to push to the dataset. SJ returns the whole day at once, so a lower limit mainly saves ticket-price requests.",
            "default": 20
          }
        }
      },
      "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
                  }
                }
              },
              "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}