https://github.com/ashwanthkumar/ip-lookup
IP Lookup Service powered by free IPInfo dataset easy to build and self host
https://github.com/ashwanthkumar/ip-lookup
Last synced: 8 months ago
JSON representation
IP Lookup Service powered by free IPInfo dataset easy to build and self host
- Host: GitHub
- URL: https://github.com/ashwanthkumar/ip-lookup
- Owner: ashwanthkumar
- Created: 2024-08-27T14:26:01.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-28T08:18:12.000Z (almost 2 years ago)
- Last Synced: 2024-12-27T12:44:49.464Z (over 1 year ago)
- Language: Go
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ip-lookup
Code to download the IpInfo free jsonl dataset and setup a lookup endpoint using sqlite as the backing store.
It supports indexing both ipv4 and ipv6 IPs and provide an endpoint:
```
GET /lookup/
```
Example response:
```
{
"ip": "35.154.199.208",
"country_name": "India",
"continent_name": "Asia"
}
```
## Usage
Build the binary locally using
```
go mod download
go build .
```
Run it via Docker.
```
docker run --restart=always -p 8080:8080 -v $(pwd):/app/data -e IP_DATA_URL="https://ipinfo.io/data/free/country.json.gz?token=your_actual_token" ashwanthkumar/ip-lookup:latest
```
1. Update `your_actual_token` with the actual token from the IP Info Dashboard.
2. Feel free to change the port where the app runs as required.
3. Make sure you mount a local folder into `/app/data` directory.
## Execution
Update the `token` from your dashboard from https://ipinfo.io/account/data-downloads. We download and
host the "Free IP to Country" dataset.
```
IP_DATA_URL="https://ipinfo.io/data/free/country.json.gz?token=..." ./ip-lookup
```
## License
MIT
## Credits
Thanks to Claude for generating most of the code in this repo.