llms.txt Content
# Country
> Country is a free IP geolocation API. Given an IP address, it returns the corresponding ISO 3166-1 alpha-2 country code. Optionally, it can return extra fields such as city, continent, subdivision, postal code, location coordinates, and ASN. No API key is required.
The API is hosted at https://api.country.is and is free for all use cases, including commercial. It rate-limits to 10 requests per second per IP. Data is sourced from MaxMind GeoLite2 and Cloudflare, updated every 24 hours.
## API Endpoints
- [GET /](https://api.country.is/): Returns `{"ip": "...", "country": "XX"}` for the requesting IP
- [GET /{ip}](https://api.country.is/8.8.8.8): Returns `{"ip": "8.8.8.8", "country": "US"}` for a given IPv4 or IPv6 address
- [POST /](https://api.country.is/): Batch lookup — send a JSON array of up to 100 IPs
- [GET /info](https://api.country.is/info): Returns `{"version": "...", "dataSources": [...], "lastUpdated": "..."}` metadata
## Extra Fields
Add `?fields=city,asn` (or any combination) to any lookup endpoint. Available fields: city, continent, subdivision, postal, location, asn.
## Errors
- `400` — Invalid IP address or malformed request
- `404` — No data found for the given IP
- `429` — Rate limit exceeded
## Self-Hosting
- [Docker image](https://hub.docker.com/r/lineofflight/country): Run `docker run -d -p 3000:3000 -e ACCOUNT_ID=... -e LICENSE_KEY=... lineofflight/country`
- [Source code](https://github.com/lineofflight/country): GitHub repository
## Optional
- [OpenAPI spec](https://api.country.is/openapi.json): Machine-readable API specification
- [Website](https://country.is): Full documentation and quick answers