{
  "openapi": "3.1.0",
  "info": {
    "title": "wtfip.io API",
    "description": "Returns the caller's public IP address and IP2Location geolocation (country, city).",
    "version": "1.0.0",
    "license": { "name": "IP2Location LITE data (CC BY-SA 4.0)", "url": "https://lite.ip2location.com" }
  },
  "servers": [{ "url": "https://wtfip.io" }],
  "paths": {
    "/json": {
      "get": {
        "operationId": "getMyIpJson",
        "summary": "Caller's public IP address and geolocation as JSON",
        "responses": {
          "200": {
            "description": "IP information for the calling client",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/IPInfo" } } }
          }
        }
      }
    },
    "/xml": {
      "get": {
        "operationId": "getMyIpXml",
        "summary": "Caller's public IP address and geolocation as XML",
        "responses": {
          "200": {
            "description": "IP information for the calling client",
            "content": { "application/xml": { "schema": { "$ref": "#/components/schemas/IPInfoXML" } } }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "IPInfo": {
        "type": "object",
        "properties": {
          "ip": { "type": "string", "examples": ["203.0.113.7"] },
          "country_name": { "type": "string", "examples": ["United States of America"] },
          "city_name": { "type": "string", "examples": ["Ashburn"] },
          "country_code": { "type": "string", "description": "ISO 3166-1 alpha-3 (lowercase)", "examples": ["usa"] },
          "country_code_short": { "type": "string", "description": "ISO 3166-1 alpha-2", "examples": ["US"] },
          "ip_list": { "type": "array", "items": { "$ref": "#/components/schemas/IPInfo" } }
        }
      },
      "IPInfoXML": {
        "type": "object",
        "xml": { "name": "wtfip.io" },
        "properties": {
          "ip": { "type": "string" },
          "country_name": { "type": "string" },
          "city_name": { "type": "string" },
          "country_code": { "type": "string", "description": "ISO 3166-1 alpha-3 (lowercase)", "examples": ["usa"] },
          "country_code_short": { "type": "string", "description": "ISO 3166-1 alpha-2" }
        }
      }
    }
  }
}