{
  "openapi": "3.0.3",
  "info": {
    "title": "LaraGeo API",
    "description": "Geolocation and Geonames API service providing IP geolocation, address geocoding, and geographic hierarchy lookup. Note: OpenAPI specification (/openapi.json) and agent skills (/skills/*) are public resources exempt from rate limiting.",
    "version": "1.0.0",
    "contact": {
      "name": "API Support",
      "url": "https://geo.mediashare.ro"
    }
  },
  "servers": [
    {
      "url": "https://geo.mediashare.ro",
      "description": "Production server"
    }
  ],
  "security": [
    {},
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/": {
      "get": {
        "summary": "Get visitor IP geolocation info",
        "description": "Retrieves geolocation information for the request's IP address. Returns JSON when the Accept header contains application/json.",
        "operationId": "getVisitorIpInfo",
        "parameters": [
          {
            "name": "Accept",
            "in": "header",
            "required": false,
            "description": "Set to application/json to receive a JSON response instead of HTML.",
            "schema": {
              "type": "string",
              "example": "application/json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Geolocation data for visitor IP or HTML view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IpApiResponse"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or expired API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "501": {
            "description": "Not Implemented - Unable to retrieve IP information",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "127.0.0.1"
                }
              }
            }
          }
        }
      }
    },
    "/get": {
      "get": {
        "summary": "Geocode IP or address",
        "description": "Geocodes a provided IP address or location address string to return city, county, country, latitude, and longitude.",
        "operationId": "geocodeLocation",
        "parameters": [
          {
            "name": "ip",
            "in": "query",
            "required": false,
            "description": "IP address to geocode. Defaults to client IP if omitted.",
            "schema": {
              "type": "string",
              "example": "8.8.8.8"
            }
          },
          {
            "name": "addr",
            "in": "query",
            "required": false,
            "description": "Address or IP string to geocode. Overrides ip parameter if provided.",
            "schema": {
              "type": "string",
              "example": "Mountain View, CA"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Geocoded address details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeocodeResult"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or expired API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/children": {
      "get": {
        "summary": "Get child geoname locations",
        "description": "Returns administrative or geographic child locations for a specified Geoname ID.",
        "operationId": "getGeonameChildren",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": false,
            "description": "Geoname ID (default: 6255149 for Earth)",
            "schema": {
              "type": "integer",
              "default": 6255149,
              "example": 6255149
            }
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Two-letter language code (default: 'en')",
            "schema": {
              "type": "string",
              "default": "en",
              "example": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of child geoname locations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ChildLocation"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or expired API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests - Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "description": "Bearer token authentication. Public access allows keyless requests (60 req/min). Authenticated requests with a valid Bearer token receive higher rate limits (1000+ req/min)."
      }
    },
    "schemas": {
      "GeocodeResult": {
        "type": "object",
        "properties": {
          "city": {
            "type": "string",
            "nullable": true,
            "example": "Mountain View"
          },
          "county": {
            "type": "string",
            "nullable": true,
            "example": "Santa Clara County"
          },
          "country": {
            "type": "string",
            "nullable": true,
            "example": "United States"
          },
          "latitude": {
            "type": "number",
            "format": "float",
            "nullable": true,
            "example": 37.3860
          },
          "longitude": {
            "type": "number",
            "format": "float",
            "nullable": true,
            "example": -122.0838
          }
        }
      },
      "ChildLocation": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "Europe"
          },
          "geonameId": {
            "type": "integer",
            "example": 6255148
          },
          "fcodeName": {
            "type": "string",
            "nullable": true,
            "example": "continent"
          },
          "latitude": {
            "type": "number",
            "format": "float",
            "nullable": true,
            "example": 48.69
          },
          "longitude": {
            "type": "number",
            "format": "float",
            "nullable": true,
            "example": 9.14
          }
        }
      },
      "IpApiResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "success"
          },
          "country": {
            "type": "string",
            "example": "United States"
          },
          "countryCode": {
            "type": "string",
            "example": "US"
          },
          "region": {
            "type": "string",
            "example": "CA"
          },
          "regionName": {
            "type": "string",
            "example": "California"
          },
          "city": {
            "type": "string",
            "example": "Mountain View"
          },
          "zip": {
            "type": "string",
            "example": "94043"
          },
          "lat": {
            "type": "number",
            "format": "float",
            "example": 37.4192
          },
          "lon": {
            "type": "number",
            "format": "float",
            "example": -122.0574
          },
          "timezone": {
            "type": "string",
            "example": "America/Los_Angeles"
          },
          "isp": {
            "type": "string",
            "example": "Google LLC"
          },
          "org": {
            "type": "string",
            "example": "Google LLC"
          },
          "as": {
            "type": "string",
            "example": "AS15169 Google LLC"
          },
          "query": {
            "type": "string",
            "example": "8.8.8.8"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "example": "Unauthorized"
          },
          "message": {
            "type": "string",
            "example": "Invalid or expired API key provided."
          }
        }
      }
    }
  }
}
