{
    "openapi": "3.1.0",
    "info": {
        "title": "AmarIP",
        "version": "1.0.0",
        "summary": "IP address and network lookup.",
        "description": "Resolve any IP address to its country, network operator and autonomous system. Answers come from a local copy of the DB-IP Lite databases, so no third-party service is contacted. No authentication is required.\n\nCoordinates are country centroids, not street addresses.",
        "license": {
            "name": "CC BY 4.0 (data)",
            "url": "https://db-ip.com"
        },
        "contact": {
            "url": "https://amarip.com/about"
        }
    },
    "servers": [
        {
            "url": "https://amarip.com",
            "description": "Production"
        }
    ],
    "paths": {
        "/api/v1/me": {
            "get": {
                "operationId": "getMyIp",
                "summary": "Details for the calling client's own IP address",
                "tags": [
                    "lookup"
                ],
                "responses": {
                    "200": {
                        "description": "Address details",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/IpInfo"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/ip/{ip}": {
            "get": {
                "operationId": "getIp",
                "summary": "Details for a specific IPv4 or IPv6 address",
                "tags": [
                    "lookup"
                ],
                "parameters": [
                    {
                        "name": "ip",
                        "in": "path",
                        "required": true,
                        "description": "IPv4 or IPv6 address",
                        "schema": {
                            "type": "string",
                            "examples": [
                                "8.8.8.8",
                                "2001:4860:4860::8888"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Address details",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/IpInfo"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Not a valid IP address",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "IpInfo": {
                "type": "object",
                "required": [
                    "ip",
                    "location",
                    "network"
                ],
                "properties": {
                    "ip": {
                        "type": "string"
                    },
                    "version": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "examples": [
                            "IPv4"
                        ]
                    },
                    "is_public": {
                        "type": "boolean"
                    },
                    "location": {
                        "type": "object",
                        "properties": {
                            "country_code": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "country": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "country_bn": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "description": "Country name in Bangla"
                            },
                            "flag": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "continent": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "city": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "latitude": {
                                "type": [
                                    "number",
                                    "null"
                                ]
                            },
                            "longitude": {
                                "type": [
                                    "number",
                                    "null"
                                ]
                            },
                            "accuracy": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "enum": [
                                    "country",
                                    "city",
                                    null
                                ]
                            },
                            "time_zone": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "local_time": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "format": "date-time"
                            },
                            "currency": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "calling_code": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            }
                        }
                    },
                    "network": {
                        "type": "object",
                        "properties": {
                            "asn": {
                                "type": [
                                    "integer",
                                    "null"
                                ]
                            },
                            "organization": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "range": {
                                "type": [
                                    "string",
                                    "null"
                                ],
                                "examples": [
                                    "8.8.8.0/24"
                                ]
                            },
                            "reverse_dns": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            }
                        }
                    }
                }
            },
            "Error": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "string"
                    },
                    "message": {
                        "type": "string"
                    }
                }
            }
        }
    }
}
