{
  "openapi": "3.1.0",
  "info": {
    "title": "Raw Timetable Data",
    "description": "Provide access to the original NeTEx datasets uploaded by data providers",
    "version": "2026.05.0"
  },
  "servers": [
    {
      "url": "https://api.entur.io/timetable/v1/timetable-data",
      "description": "Production"
    },
    {
      "url": "https://api.staging.entur.io/timetable/v1/timetable-data",
      "description": "Staging"
    },
    {
      "url": "https://api.dev.entur.io/timetable/v1/timetable-data",
      "description": "Development"
    }
  ],
  "security": [
    {
      "jwt": []
    }
  ],
  "tags": [
    {
      "name": "Raw Timetable Data",
      "description": "Give access to the original NeTEx datasets delivered by data providers"
    }
  ],
  "paths": {
    "/timetable-data/datasets/{codespace}/latest": {
      "get": {
        "tags": [
          "Raw Timetable Data"
        ],
        "summary": "Get latest dataset",
        "description": "Return the latest dataset for a given codespace",
        "operationId": "getLatestDataset",
        "parameters": [
          {
            "name": "codespace",
            "in": "path",
            "description": "The codespace identifier for the data provider",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Accept",
            "in": "header",
            "description": "Media type(s) that is/are acceptable for the response",
            "required": false,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved the latest dataset file",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "examples": {
                  "invalid-codespace": {
                    "summary": "Invalid codespace",
                    "value": {
                      "message": "The provided codespace is invalid",
                      "errorCode": "INVALID_CODESPACE"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "examples": {
                  "unauthorized": {
                    "summary": "Missing or invalid JWT",
                    "value": {
                      "message": "Authentication required",
                      "errorCode": "UNAUTHORIZED"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "examples": {
                  "no-access": {
                    "summary": "No access to codespace",
                    "value": {
                      "message": "No block viewer privileges",
                      "errorCode": "FORBIDDEN"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "examples": {
                  "not-found": {
                    "summary": "No dataset found",
                    "value": {
                      "message": "No latest dataset found for the specified codespace",
                      "errorCode": "NOT_FOUND"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "examples": {
                  "server-error": {
                    "summary": "Internal error",
                    "value": {
                      "message": "Failed to download timetable data",
                      "errorCode": "INTERNAL_ERROR"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/timetable-data/datasets/{codespace}/versions": {
      "get": {
        "tags": [
          "Raw Timetable Data"
        ],
        "summary": "List dataset versions",
        "description": "List the import keys for the latest imported datasets for a given codespace",
        "operationId": "getDatasetVersions",
        "parameters": [
          {
            "name": "codespace",
            "in": "path",
            "description": "The codespace identifier for the data provider",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved list of dataset versions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/NetexImport"
                  }
                },
                "examples": {
                  "example-1": {
                    "summary": "Example response",
                    "value": [
                      {
                        "importKey": "2024-01-15T10:30:00Z",
                        "creationDate": "2024-01-15T10:30:00.000+00:00"
                      },
                      {
                        "importKey": "2024-01-14T09:15:00Z",
                        "creationDate": "2024-01-14T09:15:00.000+00:00"
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "examples": {
                  "invalid-codespace": {
                    "summary": "Invalid codespace",
                    "value": {
                      "message": "The provided codespace is invalid",
                      "errorCode": "INVALID_CODESPACE"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "examples": {
                  "unauthorized": {
                    "summary": "Missing or invalid JWT",
                    "value": {
                      "message": "Authentication required",
                      "errorCode": "UNAUTHORIZED"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "examples": {
                  "no-access": {
                    "summary": "No access to codespace",
                    "value": {
                      "message": "No block viewer privileges",
                      "errorCode": "FORBIDDEN"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "examples": {
                  "not-found": {
                    "summary": "No datasets found",
                    "value": {
                      "message": "No datasets found for the specified codespace",
                      "errorCode": "NOT_FOUND"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "examples": {
                  "server-error": {
                    "summary": "Internal error",
                    "value": {
                      "message": "Failed to download timetable data",
                      "errorCode": "INTERNAL_ERROR"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    },
    "/timetable-data/datasets/{codespace}/version/{importKey}": {
      "get": {
        "tags": [
          "Raw Timetable Data"
        ],
        "summary": "Get specific dataset version",
        "description": "Return the dataset identified by the given codespace and import key",
        "operationId": "getDataset",
        "parameters": [
          {
            "name": "codespace",
            "in": "path",
            "description": "The codespace identifier for the data provider",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "importKey",
            "in": "path",
            "description": "The unique import key identifying the dataset version",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Accept",
            "in": "header",
            "description": "Media type(s) that is/are acceptable for the response",
            "required": false,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully retrieved the dataset file",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "examples": {
                  "invalid-params": {
                    "summary": "Invalid parameters",
                    "value": {
                      "message": "Invalid codespace or import key",
                      "errorCode": "INVALID_PARAMETERS"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "examples": {
                  "unauthorized": {
                    "summary": "Missing or invalid JWT",
                    "value": {
                      "message": "Authentication required",
                      "errorCode": "UNAUTHORIZED"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "examples": {
                  "no-access": {
                    "summary": "No access to codespace",
                    "value": {
                      "message": "No block viewer privileges",
                      "errorCode": "FORBIDDEN"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "examples": {
                  "not-found": {
                    "summary": "Dataset not found",
                    "value": {
                      "message": "Dataset not found for the specified codespace and import key",
                      "errorCode": "NOT_FOUND"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "examples": {
                  "server-error": {
                    "summary": "Internal error",
                    "value": {
                      "message": "Failed to download timetable data",
                      "errorCode": "INTERNAL_ERROR"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "parameters": [
        {
          "$ref": "#/components/parameters/ET-Client-Name"
        },
        {
          "$ref": "#/components/parameters/X-Correlation-Id"
        }
      ]
    }
  },
  "components": {
    "schemas": {
      "NetexImport": {
        "type": "object",
        "properties": {
          "importKey": {
            "type": "string"
          },
          "creationDate": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    },
    "securitySchemes": {
      "jwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "parameters": {
      "ET-Client-Name": {
        "in": "header",
        "name": "ET-Client-Name",
        "description": "\nEntur Client Header.\nIt is required that all consumers identify themselves by using this header.\nEntur will deploy strict rate-limiting policies on API-consumers who do not identify with a header and reserves the right to block unidentified consumers.\nThe structure of ET-Client-Name should be: `<company>-<application>` for companies, and `<personal name>-<application>` for individuals.",
        "schema": {
          "type": "string"
        }
      },
      "X-Correlation-Id": {
        "in": "header",
        "name": "X-Correlation-Id",
        "description": "Correlation id",
        "schema": {
          "type": "string"
        }
      }
    }
  }
}