{
  "openapi": "3.0.3",
  "info": {
    "title": "IP Geolocation API",
    "version": "1.0.0",
    "description": "Resolve any IPv4 or IPv6 address to its geographic and network context — country, region, city, ISP, ASN, and timezone — with a single API call. Primary data source is MaxMind GeoLite2 (locally hosted — no external roundtrip), with ip-api.com as fallback. Batch lookup supports up to 50 IPs per request.\n",
    "contact": {
      "name": "IP Geolocation API Support",
      "email": "api@hiroapp.cc"
    }
  },
  "servers": [
    {
      "url": "https://api.sprytools.com/v1/geo",
      "description": "Production (SpryTools API Gateway)"
    }
  ],
  "tags": [
    {
      "name": "Lookup",
      "description": "Resolve IP addresses to geo and network data"
    },
    {
      "name": "Batch",
      "description": "Bulk IP lookup"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "RapidApiProxy": []
    }
  ],
  "paths": {
    "/api/v1/geo": {
      "get": {
        "operationId": "lookupIp",
        "summary": "Look up a single IP address",
        "description": "Resolve an IPv4 or IPv6 address to country, region, city, latitude/longitude, timezone, ISP, ASN, and organization.\n",
        "tags": [
          "Lookup"
        ],
        "parameters": [
          {
            "name": "ip",
            "in": "query",
            "required": true,
            "description": "IPv4 or IPv6 address to look up",
            "schema": {
              "type": "string"
            },
            "example": "8.8.8.8"
          }
        ],
        "responses": {
          "200": {
            "description": "Geolocation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeoResult"
                },
                "example": {
                  "ip": "8.8.8.8",
                  "country_code": "US",
                  "country_name": "United States",
                  "region": "California",
                  "city": "Mountain View",
                  "latitude": 37.386,
                  "longitude": -122.0838,
                  "timezone": "America/Los_Angeles",
                  "isp": "Google LLC",
                  "asn": "AS15169",
                  "org": "Google LLC"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/geo/me": {
      "get": {
        "operationId": "lookupMyIp",
        "summary": "Look up the calling IP address",
        "description": "Automatically resolves the IP address of the API caller. No parameter needed. Reads X-Forwarded-For or X-Real-IP headers set by the proxy.\n",
        "tags": [
          "Lookup"
        ],
        "responses": {
          "200": {
            "description": "Geolocation result for caller",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeoResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/v1/geo/batch": {
      "post": {
        "operationId": "lookupIpBatch",
        "summary": "Look up multiple IP addresses in batch",
        "description": "Resolve up to 50 IP addresses in a single request. Each IP is processed concurrently. Per-IP status allows identifying partial failures.\n",
        "tags": [
          "Batch"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ips"
                ],
                "properties": {
                  "ips": {
                    "type": "array",
                    "description": "IPv4 or IPv6 addresses to look up (max 50)",
                    "items": {
                      "type": "string"
                    },
                    "minItems": 1,
                    "maxItems": 50
                  }
                }
              },
              "example": {
                "ips": [
                  "8.8.8.8",
                  "1.1.1.1"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Batch geolocation results",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchGeoResult"
                },
                "example": {
                  "count": 2,
                  "results": [
                    {
                      "ip": "8.8.8.8",
                      "status": "ok",
                      "data": {
                        "ip": "8.8.8.8",
                        "country_code": "US",
                        "country_name": "United States",
                        "city": "Mountain View"
                      }
                    },
                    {
                      "ip": "1.1.1.1",
                      "status": "ok",
                      "data": {
                        "ip": "1.1.1.1",
                        "country_code": "AU",
                        "country_name": "Australia",
                        "city": "Sydney"
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      },
      "RapidApiProxy": {
        "type": "apiKey",
        "in": "header",
        "name": "x-rapidapi-proxy-secret"
      }
    },
    "schemas": {
      "GeoResult": {
        "type": "object",
        "properties": {
          "ip": {
            "type": "string"
          },
          "country_code": {
            "type": "string",
            "nullable": true
          },
          "country_name": {
            "type": "string",
            "nullable": true
          },
          "region": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "latitude": {
            "type": "number",
            "format": "float",
            "nullable": true
          },
          "longitude": {
            "type": "number",
            "format": "float",
            "nullable": true
          },
          "timezone": {
            "type": "string",
            "nullable": true
          },
          "isp": {
            "type": "string",
            "nullable": true
          },
          "asn": {
            "type": "string",
            "nullable": true
          },
          "org": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "BatchGeoResultItem": {
        "type": "object",
        "properties": {
          "ip": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "error"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/GeoResult"
          },
          "error": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "BatchGeoResult": {
        "type": "object",
        "properties": {
          "count": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BatchGeoResultItem"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad request — missing or invalid parameters",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Query param 'ip' required"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "API key missing",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "API key required"
            }
          }
        }
      },
      "UnprocessableEntity": {
        "description": "IP could not be resolved",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "IP lookup failed"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded (100 requests per minute)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": "Rate limit exceeded"
            }
          }
        }
      }
    }
  }
}