{
  "openapi": "3.1.0",
  "info": {
    "title": "Machine Learning Forecast",
    "description": "Public access to obtain real-time forecasted traffic data produced by PTV Flows",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.ptvgroup.tech/mlf/v1"
    }
  ],
  "paths": {
    "/forecast/street/realtime": {
      "get": {
        "tags": [
          "Street forecast API"
        ],
        "description": "Get last available forecast data for a specified street",
        "operationId": "getRealTimeSingleForecastDataPlatform",
        "parameters": [
          {
            "name": "street",
            "in": "query",
            "description": "Street identifier",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 123
          },
          {
            "name": "fromnode",
            "in": "query",
            "description": "Street from node identifier",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 123
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StreetForecastResponse"
                }
              }
            }
          },
          "400": {
            "description": "Request not authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service not available",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Street forecast not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/forecast/realtime": {
      "get": {
        "tags": [
          "Street forecast API"
        ],
        "description": "Get last available forecast data for all the streets",
        "operationId": "getRealTimeForecastDataPlatform",
        "responses": {
          "200": {
            "description": "Successful Operation. Object description serialized with protobuf format. (https://protobuf.dev/)",
            "content": {
              "application/x-protobuf": {
                "schema": {
                  "$ref": "#/components/schemas/ForecastDataMessageProto"
                }
              }
            }
          },
          "400": {
            "description": "Request not authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Service not available",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ForecastResultsDto": {
        "type": "object",
        "description": "Object description of single forecast result. Used for exchange data from Street forecast API",
        "properties": {
          "totime": {
            "type": "string",
            "format": "date-time",
            "description": "End time interval reference"
          },
          "fromtime": {
            "type": "string",
            "format": "date-time",
            "description": "Start time interval reference"
          },
          "creationtime": {
            "type": "string",
            "format": "date-time",
            "description": "Creation time interval reference"
          },
          "flow": {
            "type": "number",
            "format": "float",
            "description": "Estimated flow value (veh/h) ",
            "example": "3000 veh/h"
          },
          "speed": {
            "type": "number",
            "format": "float",
            "description": "Estimated speed value (km/h) ",
            "example": "30 km/h"
          }
        }
      },
      "ForecastStreetDto": {
        "type": "object",
        "description": "Object description of forecast result location. Used for exchange data from Street forecast API",
        "properties": {
          "streetIdno": {
            "type": "integer",
            "format": "int32",
            "description": "Street number reference",
            "example": 4587
          },
          "tail": {
            "type": "integer",
            "format": "int32",
            "description": "Street from node number reference",
            "example": 4587
          },
          "openLrCode": {
            "type": "string",
            "description": "Location Open LR reference",
            "example": "4587"
          }
        }
      },
      "StreetForecastResponse": {
        "type": "object",
        "description": "Object description of collection of forecast results. Used for exchange data from Street forecast API",
        "properties": {
          "forecastStreet": {
            "$ref": "#/components/schemas/ForecastStreetDto"
          },
          "forecastResults": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForecastResultsDto"
            }
          }
        }
      },
      "CausingError": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "errorCode": {
            "type": "string",
            "description": "        A constant string that can be used to identify this error class programmatically. An errorCode can have **details** to provide information in additional properties which are described with the code they apply to.\n        Note that additional errorCodes as well as the **details** of existing errorCodes may be added at any time.\n\n        HTTP status code: 400\n        * GENERAL_UNAUTHENTICATED: Invalid or missing authentication credentials\n        HTTP status code: 500\n        * GENERAL_VALIDATION_ERROR: The validation of the request failed. Details can be found in causes\n        HTTP status code: 503\n        * GENERAL_SERVICE_UNAVAILABLE: The request could not be processed due to an internal error\n        HTTP status code: 404\n        * GENERAL_RESOURCE_NOT_FOUND: A requested resource does not exist\n\n\n\n"
          },
          "parameter": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "additionalProperties": {}
          }
        },
        "required": [
          "description",
          "errorCode"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "traceId": {
            "type": "string",
            "description": "A unique identifier specific to this error instance. It can be used to trace errors by the support team."
          },
          "errorId": {
            "type": "string",
            "description": "A unique identifier specific to this error instance. It can be used to trace errors by the support."
          },
          "description": {
            "type": "string",
            "description": "A human readable message that describes the error"
          },
          "errorCode": {
            "type": "string",
            "description": "        A constant string that can be used to identify this error class programmatically. An errorCode can have **details** to provide information in additional properties which are described with the code they apply to.\n        Note that additional errorCodes as well as the **details** of existing errorCodes may be added at any time.\n\n        HTTP status code: 400\n        * GENERAL_UNAUTHENTICATED: Invalid or missing authentication credentials\n\n        HTTP status code: 500\n        * GENERAL_VALIDATION_ERROR: The validation of the request failed. Details can be found in causes\n\n        HTTP status code: 503\n        * GENERAL_SERVICE_UNAVAILABLE: The request could not be processed due to an internal error\n\n        HTTP status code: 404\n        * GENERAL_RESOURCE_NOT_FOUND: A requested resource does not exist\n\n\n\n"
          },
          "causes": {
            "type": "array",
            "description": "A list of affected parameters and/or properties that caused this error.",
            "items": {
              "$ref": "#/components/schemas/CausingError"
            }
          },
          "details": {
            "type": "object",
            "additionalProperties": {},
            "description": "Additional properties specific to this error class."
          }
        },
        "required": [
          "description",
          "errorCode",
          "traceId"
        ]
      },
      "ForecastDataMessageProto": {
        "type": "object",
        "description": "Object description of forecast result Object. Used for exchange data from Street forecast API. serialized with protobuf format. (https://protobuf.dev/)\n\nProto definition:\n\n        syntax = \"proto3\";\n\n        import \"google/protobuf/timestamp.proto\";\n\n        package com.ptvgroup.mlf.common.messagehandling.forecast;\n\n\n        message ForecastData {\n\n        \tmessage StreetForecast {  \n        \t\tint32 id =1;  \n        \t\tint32 fromNode=2;  \n        \t\trepeated Forecast forecast=3;\n        \t\tstring openLRcode=4;\n        \t} \n\n        \tmessage Forecast {\n        \t\tgoogle.protobuf.Timestamp start=1;\n        \t\tgoogle.protobuf.Timestamp end=2;\n        \t\tbool flow_valid = 3;\n        \t\tdouble flow=4;\n        \t\tbool speed_valid= 5;\n        \t\tdouble speed=6;\n        \t\tstring timezone = 7;\n        \t}\n\n        \trepeated StreetForecast streetForecast=1;\n\n        }\n\n\n",
        "properties": {
          "streetForecast": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StreetForecastProto"
            }
          }
        }
      },
      "ForecastProto": {
        "type": "object",
        "description": "Protocol buffers of forecast result object",
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time",
            "description": "Start time of data validity"
          },
          "end": {
            "type": "string",
            "format": "date-time",
            "description": "End time of data validity"
          },
          "flow_valid": {
            "type": "boolean",
            "description": "validity of flow value"
          },
          "speed_valid": {
            "type": "boolean",
            "description": "validity of speed value"
          },
          "speed": {
            "type": "number",
            "format": "double",
            "description": "speed value"
          },
          "flow": {
            "type": "number",
            "format": "double",
            "description": "flow value"
          },
          "timezone": {
            "type": "string",
            "description": "timezone of local data"
          }
        }
      },
      "StreetForecastProto": {
        "type": "object",
        "description": "Protocol buffers Object description of forecast result",
        "properties": {
          "street": {
            "type": "integer",
            "format": "int32"
          },
          "fromnode": {
            "type": "integer",
            "format": "int32"
          },
          "openLRcode": {
            "type": "string"
          },
          "forecast": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ForecastProto"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "apiKey"
      }
    }
  },
  "security": [
    {
      "apiKeyAuth": []
    }
  ]
}