Skip to content
/ gopi Public

Gopi - Simple API for get geo information about your IP Address or other IP

License

Notifications You must be signed in to change notification settings

troke12/gopi

Repository files navigation

gopi

Idea

This idea come from IP zxq and literaly i clone it, also already used for my project.

Download GeoIP2Lite Database

First of all, we need to download the database from Maxmind and below you can use this to download the db and remember to change YOUR_LICENSE_KEY

You can obtain LICENSE KEY here

wget -O geoip.tar.gz "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=YOUR_LICENSE_KEY&suffix=tar.gz"
tar -zxvf geoip.tar.gz
mv geoip.tar.gz data

Development

git clone https://github.com/troke12/gopi
cd gopi
cp .env.example .env
go build
./gopi

Docker

If you want to use docker just add some build-arg in build docker

docker build --build-arg LICENSEY_KEY=LICENSEY_KEY --build-arg API_FGIP=API_FREEGEOIP --build-arg PORT="localhost:3045" --build-arg ROLLBARTOKEN=ROLLBAR_TOKEN . -t gopi

docker run -d p 3045:3045 --name gopi gopi

It will automatically download the latest MaxMindDB and extract it to the data folder

Routes

  • / - get your current information
  • /8.8.8.8/country - get the country iso code
  • /8.8.8.8 - get the information another ip

Result

{
    "ip":"127.0.0.1",
    "city":"Jakarta",
    "region":"Jakarta",
    "country":"ID",
    "country_full":"Indonesia",
    "continent":"AS",
    "continent_full":"Asia",
    "loc":"-6.2092,106.8200",
    "postal":""
}

About

Gopi - Simple API for get geo information about your IP Address or other IP

Resources

License

Stars

Watchers

Forks

Packages

No packages published