{
  "openapi": "3.1.0",
  "info": {
    "title": "Geoapify Batch API",
    "version": "0.1.0",
    "description": "OpenAPI specification for Geoapify generic asynchronous batch endpoints."
  },
  "servers": [
    {
      "url": "https://api.geoapify.com/v1"
    }
  ],
  "tags": [
    {
      "name": "Batch",
      "description": "Submit asynchronous batch jobs and retrieve batch results."
    }
  ],
  "paths": {
    "/batch": {
      "post": {
        "tags": [
          "Batch"
        ],
        "operationId": "submitBatchJob",
        "summary": "Submit a generic batch job",
        "description": "Submit up to 1000 inputs for one supported Geoapify API endpoint.",
        "parameters": [
          {
            "name": "apiKey",
            "in": "query",
            "required": true,
            "description": "Geoapify API key.",
            "schema": {
              "type": "string"
            },
            "example": "YOUR_API_KEY"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchSubmitRequest"
              },
              "example": {
                "api": "/v1/geocode/search",
                "params": {
                  "lang": "en",
                  "limit": 1
                },
                "inputs": [
                  {
                    "params": {
                      "text": "Berlin"
                    }
                  },
                  {
                    "params": {
                      "text": "Paris"
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch job submission response.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/BatchJobResponse"
                    },
                    {
                      "$ref": "#/components/schemas/BatchResultResponse"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid Geoapify API key."
          },
          "404": {
            "description": "Batch job was not found."
          },
          "429": {
            "description": "Rate limit or quota exceeded."
          },
          "500": {
            "description": "Internal gateway error."
          }
        }
      },
      "get": {
        "tags": [
          "Batch"
        ],
        "operationId": "getBatchJob",
        "summary": "Get generic batch job result",
        "description": "Retrieve the status or result for a generic batch job.",
        "parameters": [
          {
            "name": "apiKey",
            "in": "query",
            "required": true,
            "description": "Geoapify API key.",
            "schema": {
              "type": "string"
            },
            "example": "YOUR_API_KEY"
          },
          {
            "name": "id",
            "in": "query",
            "required": true,
            "description": "Batch job identifier returned by the submit endpoint.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{32}$"
            },
            "example": "0123456789abcdef0123456789abcdef"
          }
        ],
        "responses": {
          "200": {
            "description": "Batch job status or result.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/BatchJobResponse"
                    },
                    {
                      "$ref": "#/components/schemas/BatchResultResponse"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid Geoapify API key."
          },
          "404": {
            "description": "Batch job was not found."
          },
          "429": {
            "description": "Rate limit or quota exceeded."
          },
          "500": {
            "description": "Internal gateway error."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "BatchSubmitRequest": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "api",
          "inputs"
        ],
        "properties": {
          "api": {
            "type": "string",
            "enum": [
              "/v1/isoline",
              "/v1/routing",
              "/v1/places",
              "/v1/geometry",
              "/v1/geocode/search",
              "/v1/geocode/reverse",
              "/v1/mapmatching",
              "/v2/places",
              "/v2/place-info",
              "/v2/place-details",
              "/v1/ipinfo",
              "/v1/routeplanner",
              "/v1/routematrix",
              "/v1/boundaries/part-of",
              "/v1/boundaries/consists-of"
            ],
            "description": "Geoapify API endpoint to execute for each batch input."
          },
          "params": {
            "type": "object",
            "additionalProperties": true,
            "description": "Request-level query parameters applied to all batch inputs."
          },
          "body": {
            "type": "object",
            "additionalProperties": true,
            "description": "Request-level body applied to all batch inputs."
          },
          "inputs": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "$ref": "#/components/schemas/BatchInput"
            }
          },
          "priority": {
            "type": "number",
            "minimum": 0.01,
            "maximum": 1,
            "description": "Optional batch processing priority factor."
          }
        }
      },
      "BatchInput": {
        "type": "object",
        "additionalProperties": true,
        "anyOf": [
          {
            "required": [
              "params"
            ]
          },
          {
            "required": [
              "body"
            ]
          }
        ],
        "properties": {
          "params": {
            "type": "object",
            "additionalProperties": true,
            "description": "Input-specific query parameters."
          },
          "body": {
            "type": "object",
            "additionalProperties": true,
            "description": "Input-specific request body."
          }
        }
      },
      "BatchJobResponse": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-f0-9]{32}$",
            "description": "Batch job identifier."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "URL for polling the batch job."
          },
          "status": {
            "type": "string",
            "description": "Batch job status."
          }
        }
      },
      "BatchResultResponse": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-f0-9]{32}$"
          },
          "status": {
            "type": "string"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      }
    }
  }
}
