{
  "openapi": "3.0.3",
  "info": {
    "title": "IPSnapshot IP Lookup API",
    "description": "Free IP lookup: geolocation (country, region, city, continent), ASN and ISP, VPN, Tor and datacenter flags and a risk score, from a local dataset with no external calls at request time. Geo and ASN data by DB-IP Lite (CC BY 4.0). Works for IPv4 and IPv6; /api/ip/self answers about the caller. Keyless use is limited per IP per day; a free IPNOVA API key raises the limit.",
    "version": "1.0.0",
    "contact": {
      "email": "hello@ipnova.com",
      "url": "https://ipsnapshot.com/ip-lookup-api"
    }
  },
  "servers": [
    {
      "url": "https://ipsnapshot.com"
    }
  ],
  "paths": {
    "/api/ip/{ip}": {
      "get": {
        "summary": "Look up an IP address",
        "description": "IPv4 or IPv6 address, or the literal value self for the caller's own address.",
        "operationId": "lookupIp",
        "security": [
          {},
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "ip",
            "in": "path",
            "required": true,
            "description": "IP address, e.g. 8.8.8.8, or self",
            "schema": {
              "type": "string",
              "example": "8.8.8.8"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Lookup result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IpResult"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key",
        "description": "Free IPNOVA API key from https://api.ipnova.com (also accepted as ?key= query parameter). Keyless requests share a per-IP daily limit."
      }
    },
    "schemas": {
      "IpResult": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": true
          },
          "ip": {
            "type": "string",
            "example": "8.8.8.8"
          },
          "data": {
            "type": "object",
            "properties": {
              "ip_version": {
                "type": "integer",
                "enum": [
                  4,
                  6
                ]
              },
              "country_code": {
                "type": "string",
                "example": "US"
              },
              "country": {
                "type": "string",
                "example": "United States"
              },
              "region": {
                "type": "string"
              },
              "city": {
                "type": "string"
              },
              "continent": {
                "type": "string"
              },
              "asn": {
                "type": "string",
                "example": "AS15169"
              },
              "isp": {
                "type": "string",
                "example": "Google LLC"
              },
              "is_vpn": {
                "type": "boolean"
              },
              "is_tor": {
                "type": "boolean"
              },
              "is_datacenter": {
                "type": "boolean"
              },
              "risk_level": {
                "type": "string",
                "example": "low"
              },
              "risk_score": {
                "type": "integer",
                "minimum": 0,
                "maximum": 100
              }
            }
          },
          "page": {
            "type": "string",
            "format": "uri"
          },
          "attribution": {
            "type": "string",
            "example": "Data by IPSnapshot.com - free IP lookup API. Geo/ASN: DB-IP Lite (CC BY 4.0)."
          },
          "docs": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "example": false
          },
          "error": {
            "type": "boolean",
            "example": true
          },
          "reason": {
            "type": "string",
            "enum": [
              "invalid_input",
              "rate_limit",
              "daily_limit",
              "unknown_endpoint",
              "method_not_allowed"
            ]
          },
          "message": {
            "type": "string"
          },
          "docs": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error envelope with a machine-readable reason field",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
