Note: this setup has only been testing for macOS.
- clone this repo and
cd
to the root of the repo - Install pyenv and pyenv-virtualenv:
brew install pyenv pyenv-virtualenv
- Add the following to your
~/.bashrc
or~/.zshrc
file:
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
- Ensure your RC file has been run in your current shell:
source ~/.zshrc
orsource ~/.zshrc
- install Python version 3.11.2:
pyenv install 3.11.2
- Create a new virtual enviornemtn:
pyenv virtualenv 3.11.2 pangea
- Link the virutal enviornemtn to the repo:
pyenv local pangea
- Ensure you are using the enviornment you just created:
pyenv which python
you should see something like:.pyenv/versions/pangea/bin/python
. if you don't seepangea
somewhere in the path, you've made a mistake somewhere pip install -r requriements.txt
- Create a Pangea account: https://pangea.cloud/docs/admin-guide/getting-started/create-account/
- Login to Pangea console
- Go to the Tokens page: https://console.pangea.cloud/project/tokens and click on the the "Create" button in the upper right hand corner
- Enter a name for the token and click the box labeled
IP Intel
then click theCreate token
button - Next, in the list of tokens, click the copy symbole on the token you just created and paste it in the
.env
file in the repo in plac eofCHANGE_ME
for the value ofPANGEA_INTEL_TOKEN
- Run
python pangea-ip-intel-example.py
You should see similar output to what is below:$ python pangea-ip-intel-example.py Calling Pangea IP Intel Geolocate API with IP Address '93.231.182.110'... { 'area_codes': '?', 'city': 'unna', 'city_code': 7627, 'city_conf': 95, 'connection_speed': 'xdsl', 'connection_type': 'wifi', 'continent_code': 5, 'country': 'deu', 'country_code': 276, 'country_conf': 99, 'country_name': 'Federal Republic Of Germany', 'gmt_offset': 200, 'in_dst': 'y', 'internal_code': 24, 'latitude': 51.56, 'longitude': 7.65, 'max_ip': '93.231.182.111', 'metro_code': 276002, 'min_ip': '93.231.182.104', 'postal_code': '59425', 'postal_conf': 90, 'region': 'nw', 'region_code': 10528, 'region_conf': 99, 'timezone_name': 'europe/berlin', 'two_letter_country': 'de'}
The IP Intel API response has two parts: data
and raw_data
- Data:
{ 'city': 'unna', 'country': 'Federal Republic Of Germany', 'country_code': 'de', 'latitude': 51.56, 'longitude': 7.65, 'postal_code': '59425'}
- Raw Data:
{ 'area_codes': '?', 'city': 'unna', 'city_code': 7627, 'city_conf': 95, 'connection_speed': 'xdsl', 'connection_type': 'wifi', 'continent_code': 5, 'country': 'deu', 'country_code': 276, 'country_conf': 99, 'gmt_offset': 200, 'in_dst': 'y', 'internal_code': 24, 'latitude': 51.56, 'longitude': 7.65, 'max_ip': '93.231.182.111', 'metro_code': 276002, 'min_ip': '93.231.182.104', 'postal_code': '59425', 'postal_conf': 90, 'region': 'nw', 'region_code': 10528, 'region_conf': 99, 'timezone_name': 'europe/berlin', 'two_letter_country': 'de'}
these two sets of data are idential except that country
spells out the name of the country (e.g. Federal Republic Of Germany
) in data
while country
uses the country abreviation in raw_data
(e.g. deu
). In the future combining these two sets of data into one might be benefical (you country_name
could be used for the spelled out name).