All Projects → ipapi-co → ipapi-python

ipapi-co / ipapi-python

Licence: MIT license
Python bindings for https://ipapi.co (IP Address Location) - Use with python / django / flask for IP address location lookup

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to ipapi-python

IP2Location-PHP-Module
This module is a PHP module that enables the user to find the country, region, city, coordinates, zip code, ISP, domain name, timezone, connection speed, IDD code, area code, weather station code, weather station name, mobile, usage types, address type, IAB category, etc that any IP address or host name originates from.
Stars: ✭ 154 (+266.67%)
Mutual labels:  ipv6, geolocation, ipv4, ip-address, ip-lookup, ip-location
ip2location-nginx
Nginx module that allows user to lookup for geolocation information using IP2Location database.
Stars: ✭ 33 (-21.43%)
Mutual labels:  ipv6, geolocation, ipv4, ip-address, ip-lookup, ip-location
Geolocate-IP-Browser-Extension
A browser extension, which shows you the origin of your IP address.
Stars: ✭ 21 (-50%)
Mutual labels:  ipv6, geolocation, ipv4, ip-address, ip-geolocation
IP2Country
Ip to country mapping
Stars: ✭ 39 (-7.14%)
Mutual labels:  geolocation, ip-country, ip-lookup, ip-geolocation, ipgeolocation
IP2Location-C-Library
IP2Location C library enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather station code, weather station name, mobile, usage types, etc that any IP address or hostname originates from.
Stars: ✭ 37 (-11.9%)
Mutual labels:  ipv6, geolocation, ipv4, ip-address, ip-lookup
node-ip2region
IP/IPv6 to region on Node.js (IP/IPv6 地址到区域运营商)
Stars: ✭ 95 (+126.19%)
Mutual labels:  ipv6, ip-address, ip-lookup, ip-location
ip
Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
Stars: ✭ 212 (+404.76%)
Mutual labels:  ipv6, ipv4, ip-address
Ipwhois
Retrieve and parse whois data for IPv4 and IPv6 addresses
Stars: ✭ 432 (+928.57%)
Mutual labels:  ipv6, ipv4, ip-address
Ipaddress
Java library for handling IP addresses and subnets, both IPv4 and IPv6
Stars: ✭ 197 (+369.05%)
Mutual labels:  ipv6, ipv4, ip-address
ip2location-nginx
This is IP2Location Nginx module that enables the user to find the country, region (state), city, latitude, longitude, zip code, time zone, ISP, domain name, connection type, area code, weather, mobile network, elevation, usage type, address type and IAB category by IP address or hostname originates from.
Stars: ✭ 38 (-9.52%)
Mutual labels:  geolocation, ip-lookup, ip-geolocation
Ipnetwork
A library to work with CIDRs in rust
Stars: ✭ 64 (+52.38%)
Mutual labels:  ipv6, ipv4, ip-address
php-ip-anonymizer
IP address anonymizer library for PHP
Stars: ✭ 55 (+30.95%)
Mutual labels:  ipv6, ipv4, ip-address
private-ip
Check if IP address is private.
Stars: ✭ 26 (-38.1%)
Mutual labels:  ipv6, ipv4, ip-address
ip2location-piwik
Use IP2Location geolocation database to lookup for accurate visitor location in Matomo (Piwik) 3.x. It enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation, usage type, address type and IAB category that any IP address o…
Stars: ✭ 26 (-38.1%)
Mutual labels:  geolocation, ip-lookup, ip-geolocation
go-inet
A Go library for reading, formatting, sorting, lookup and converting IP-addresses and IP-blocks
Stars: ✭ 14 (-66.67%)
Mutual labels:  ipv6, ipv4, ip-lookup
ipaddress
Data analysis of IP addresses and networks
Stars: ✭ 20 (-52.38%)
Mutual labels:  ipv6, ipv4, ip-address
Ip Num
A TypeScript/JavaScript library for working with ASN, IPv4, and IPv6 numbers. It provides representations of these internet protocol numbers with the ability to perform various IP related operations like parsing, validating etc. on them
Stars: ✭ 113 (+169.05%)
Mutual labels:  ipv6, ipv4, ip-address
ip2location-cakephp
IP2Location CakePHP plugin enables the user to find the country, region, city, coordinates, zip code, time zone, ISP, domain name, connection type, area code, weather, MCC, MNC, mobile brand name, elevation, usage type, IP address type and IAB advertising category from IP address using IP2Location database.
Stars: ✭ 17 (-59.52%)
Mutual labels:  geolocation, ip-lookup, ip-geolocation
IPpy
🚀 Ping IP addresses and domains in parallel to find the accessible and inaccessible ones.
Stars: ✭ 54 (+28.57%)
Mutual labels:  ipv6, ipv4, ip-address
cli
Official Command Line Interface for the IPinfo API (IP geolocation and other types of IP data)
Stars: ✭ 1,279 (+2945.24%)
Mutual labels:  ip-address, ip-lookup, ip-geolocation

ipapi Python Library ~ ipapi.co by Kloudend, Inc.

IP Address Location | IP Lookup | IP Geolocation API

The ipapi Python library provides convenient access to the IP address location service from applications written in the Python language. It makes it easy to harness the potential of the IP geolocation API.

Details on free IP lookup and ipapi pricing plans

Documentation

See the ipapi API docs

Installation

pip install --upgrade ipapi

or Install from source with:

python setup.py install

Requirements

Python 2.7+ or Python 3.4+

QuickStart

>>> import ipapi

>>> ipapi.location()
{
  "ip": "8.8.8.8",
  "city": "Mountain View",
  "country": "US",
  "timezone": "America/Los_Angeles",
  ...
}

Usage : As an IP Location library

import ipapi

ipapi.location(ip, key, output)

Options

Argument Description
ip IP Address (IPv4 or IPv6) that you wish to locate.
If omitted, it defaults to the your machine's IP
key API key (for paid plans).
Omit it or set key=None for usage under free IP Location tier.
output The desired output from the API.
For complete IP location object, valid values are json, csv, xml, yaml.
To retrieve a specific field (e.g. city, country etc. as text), valid values are [1].
If omitted or None, gets the entire location data as json

[1] Fields supported by the API : ip, city, region, region_code, country, country_code, country_code_iso3, country_capital, country_tld, country_name, continent_code, in_eu, postal, latitude, longitude, timezone, utc_offset, country_calling_code, currency, currency_name, languages, country_area, country_population, latlong, asn, org

Examples

  1. Find the location of your IP address
>>> ipapi.location()

The output would be a JSON object like this (assuming your IP is '50.1.2.3') :

{
    "ip": "50.1.2.3",
    "city": "Sacramento",
    "region": "California",
    "region_code": "CA",
    "country": "US",
    "country_code": "US",
    "country_code_iso3": "USA",
    "country_capital": "Washington",
    "country_tld": ".us",
    "country_name": "United States",
    "continent_code": "NA",
    "in_eu": false,
    "postal": "95817",
    "latitude": 38.548,
    "longitude": -121.4597,
    "timezone": "America/Los_Angeles",
    "utc_offset": "-0700",
    "country_calling_code": "+1",
    "currency": "USD",
    "currency_name": "Dollar",
    "languages": "en-US,es-US,haw,fr",
    "country_area": 9629091.0,
    "country_population": 310232863.0,
    "asn": "AS7065",
    "org": "SONOMA"
}
  1. Find the location of an IP address
>>> ipapi.location(ip='8.8.8.8')
{
    "ip": "8.8.8.8",
    "city": "Mountain View",
    "region": "California",
    ...
}

You can also use an IPv6 address e.g.

>>> ipapi.location(ip='2001:4860:1::1')
  1. Find the location of an IP address in xmlformat (other formats :json, csv,yaml)
>>> ipapi.location(ip='8.8.8.8', output='xml')
'<?xml version="1.0" encoding="utf-8"?>
  <root>
    <ip>8.8.8.8</ip>
    <city>Mountain View</city>
    ...
  </root>'
  1. Find your external IP address
>>> ipapi.location(output='ip')
'50.1.2.3'
  1. Find the city from an IP address
>>> ipapi.location(ip='8.8.8.8', output='city')
'Mountain View'
  1. Find the country code from an IP address
>>> ipapi.location(ip='8.8.8.8', output='country_code')
'US'
  1. Find the region of an IP address
>>> ipapi.location(ip='8.8.8.8', output='region_code')
'CA'
  1. Find if an IP address is located in the European Union
>>> ipapi.location(ip='8.8.8.8', output='in_eu')
'False'
  1. Find the latitude and longitude of an IP address
>>> ipapi.location(ip='1.2.3.4', output='latlong')
'-27.473101,153.014046'
  1. Find the postal code of an IP address
>>> ipapi.location(ip='1.2.3.4', output='postal')
'4101'
  1. Find the timezone of an IP address
>>> ipapi.location(ip='1.2.3.4', output='timezone')
'Australia/Brisbane'
  1. Find the currency of an IP address
>>> ipapi.location(ip='1.2.3.4', output='currency')
'AUD'
  1. Find the ASN of an IP address
>>> ipapi.location(ip='1.1.1.1', output='asn')
'AS13335'
  1. Find the Organization of an IP address
>>> ipapi.location(ip='8.8.8.8', output='org')
'GOOGLE'

Usage : As an IP Location command line utility

ln -s /<virtual-env-path>/lib/python3.8/site-packages/ipapi ipapi

$ python ipapi -i <IP Address> -k <API KEY> -o <Output Format>
OR
$ python ipapi --ip <IP Address> --key <API KEY> --output <Output Format>

where the options ip, key, output are defined above.

Examples

  1. Get your IP Geolocation
$ python ipapi

The output would be a JSON object like this (assuming your IP is 50.1.2.3) :

{
    "ip": "50.1.2.3",
    "city": "Sacramento",
    "region": "California",
    "region_code": "CA",
    "country": "US",
    "country_code": "US",
    "country_code_iso3": "USA",
    "country_capital": "Washington",
    "country_tld": ".us",
    "country_name": "United States",
    "continent_code": "NA",
    "in_eu": false,
    "postal": "95817",
    "latitude": 38.548,
    "longitude": -121.4597,
    "timezone": "America/Los_Angeles",
    "utc_offset": "-0700",
    "country_calling_code": "+1",
    "currency": "USD",
    "currency_name": "Dollar",
    "languages": "en-US,es-US,haw,fr",
    "country_area": 9629091.0,
    "country_population": 310232863.0,
    "asn": "AS7065",
    "org": "SONOMA"
}
  1. Get the geolocation of an IP address
$ python ipapi -i '8.8.8.8'
{
    "ip": "8.8.8.8",
    "city": "Mountain View",
    "region": "California",
    ...
}
  1. Get the location of an IP in xml format (other formats : json, csv, yaml)
$ python ipapi -i '8.8.8.8' -o xml
'<?xml version="1.0" encoding="utf-8"?>
  <root>
    <ip>8.8.8.8</ip>
    <city>Mountain View</city>
    ...
  </root>'
  1. Get your external IP address
$ python ipapi -o ip
'50.1.2.3'
  1. Get the city of an IP address
$ python ipapi -i '8.8.8.8' -o city
'Mountain View'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].