IPInfo In-Memory API is a high-performance HTTP service written in Go for IPv4 and IPv6 metadata lookup using the IPInfo offline CSV dataset.
The service is designed for read-heavy workloads, low latency, and predictable behavior. All lookups are performed entirely in memory — no external API calls are made during request handling.
- IPv4 and IPv6 support
- In-memory lookups only ($O(\log N)$)
-
Offline IPInfo CSV dataset (
.csv.gz) - Automatic gzip handling
- Atomic dataset reload (no downtime)
- Disk cache of the last successful dataset
- Periodic background refresh
-
Manual reload via HTTP or
SIGHUP - Separate liveness and readiness endpoints
- Graceful shutdown
- Single static binary (CGO disabled)
- The IPInfo dataset is downloaded as a compressed CSV file.
- The file is decompressed and parsed.
- Parsed data is stored in optimized in-memory structures.
- Lookups are performed using binary search.
- Dataset reloads replace the in-memory data atomically.
Note: During normal operation, no network calls are made.
The service expects an IPInfo CSV dataset with the following columns:
network(CIDR, IPv4 or IPv6)countrycountry_codecontinentcontinent_codeasn(required, may be empty)as_name(required, may be empty)as_domain(required, may be empty)
Returns metadata for an IPv4 or IPv6 address.
Example response:
{
"network": "8.8.8.0/24",
"country": "United States",
"country_code": "US",
"continent": "North America",
"continent_code": "NA",
"asn": "AS15169",
"as_name": "Google LLC",
"as_domain": "google.com"
}Returns 404 if the IP is not found.
Liveness probe.
Always returns 200 OK.
Performs no dataset access.
Intended for container orchestration and monitoring.
Readiness probe.
Returns 200 OK only when the dataset is loaded.
Returns 503 during startup or failed reload.
Triggers a dataset reload.
Reload runs asynchronously.
Uses the same logic as periodic refresh.
Safe to call while the service is running.
Configuration is provided via config.yaml.
server:
listen: ":8090"
shutdown_timeout: 10s
ipinfo:
dump_url: "https://ipinfo.io/data/ipinfo_lite.csv.gz"
token: ""
refresh_interval: 24h
download_timeout: 30s
cache_file: "./data/ipinfo.csv"The IPInfo token can be provided via environment variable:
HL_APP_IPINFO_TOKEN=your_token_hereRequirements: Go 1.25.5 or newer
export HL_APP_IPINFO_TOKEN=your_token
go run main.goThe first startup may take longer due to dataset download and parsing.
Prebuilt binaries are available via GitHub Releases for:
- Linux (amd64, arm64)
- macOS (arm64)
Each release includes SHA256 checksums.
- No mutexes in the request path
- No allocations during lookups
- Immutable datasets
- Atomic memory swaps
- Disk and memory consistency
- Simple failure modes
This service favors determinism and performance over configurability.