- Create modular architecture with separate packages for config, database, HTTP, logging, and state management - Implement Cobra CLI with daemon command - Set up Uber FX dependency injection - Add Chi router with health check and IP lookup endpoints - Implement GeoIP database downloader with automatic updates - Add state persistence for tracking database download times - Include comprehensive test coverage for all components - Configure structured logging with slog - Add Makefile with test, lint, and build targets - Support both IPv4 and IPv6 lookups - Return country, city, ASN, and location data in JSON format |
||
---|---|---|
cmd/ipapi | ||
internal | ||
.golangci.yml | ||
AGENTS.md | ||
CLAUDE.md | ||
go.mod | ||
go.sum | ||
Makefile | ||
README.md |
ipapi
IP API is a simple IP information REST api designed for self-hosting.
On initial startup, it fetches:
- https://git.io/GeoLite2-ASN.mmdb
- https://git.io/GeoLite2-City.mmdb
- https://git.io/GeoLite2-Country.mmdb
It then provides a simple REST api at:
It supports IPv4 and IPv6.
It has a state file at /var/lib/ipapi/daemon.json that keeps track of the last download times of the databases, and it replaces them if they are older than 1 week (or, of course, if they are missing).
Usage
curl https://ipapi.example.com/api/8.8.8.8
Libraries
- go stdlib log/slog
- cobra cli
- uber/fx DI
- go-chi/chi router