Official Python Library for IPinfo API (IP geolocation and other types of IP data)
Repo ipinfo/python, read from GitHub 1 min ago. ipinfo has not joined Take My Repo.
ipinfo/python is a public repo on GitHub by ipinfo. Official Python Library for IPinfo API (IP geolocation and other types of IP data). It declares the Apache-2.0 license on GitHub. It is written mainly in Python, has 572 stars and last changed on 2026-10-21. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-19.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
This is the official Python client library for the IPinfo.io IP address API, allowing you to look up your own IP address, or get any of the following details for an IP:
You'll need an IPinfo API access token, which you can get by signing up for a free account at https://ipinfo.io/signup.
The free plan is limited to 50,000 requests per month, and doesn't include some of the data fields such as IP type and company data. To enable all the data fields and additional request volumes see https://ipinfo.io/pricing
The library also supports the Lite API, see the Lite API section for more info.
This package works with Python 3.5 or greater. However, we only officially support non-EOL Python versions.
pip install ipinfo
>>> import ipinfo >>> access_token = '123456789abc' >>> handler = ipinfo.getHandler(access_token) >>> ip_address = '216.239.36.21' >>> details = handler.getDetails(ip_address) >>> details.city 'Mountain View' >>> details.loc '37.3861,-122.0840'
An asynchronous handler is available as well, and can be accessed and used in almost the same exact way as the synchronous handler:
>>> import ipinfo >>> access_token = '123456789abc' >>> handler = ipinfo.getHandlerAsync(access_token) >>> ip_address = '216.239.36.21' >>> async def do_req(): ... details = await handler.getDetails(ip_address) ... print(details.city) ... print(details.loc) ... >>> >>> import asyncio >>> loop = asyncio.get_event_loop() >>> loop.run_until_complete(do_req()) Mountain View 37.4056,-122.0775 >>> >>> ip_address = '1.1.1.1' >>> loop.run_until_complete(do_req()) New York City 40.7143,-74.0060
Internally the library uses aiohttp, but as long as you provide an event
loop (as in this example via asyncio), it shouldn't matter.
NOTE: due to API changes in the asyncio library, the asynchronous implementation only supports Python version 3.9 and 3.10.
The Handler.getDetails() method accepts an IP address as an optional, positional argument. If no IP address is specified, the API will return data for the IP address from which it receives the request.
>>> import ipinfo >>> access_token = '123456789abc' >>> handler = ipinfo.getHandler(access_token) >>> details = handler.getDetails() >>> details.city 'Mountain View' >>> details.loc '37.3861,-122.0840'
The IPinfo library can be authenticated with your IPinfo API token, which is passed in as a positional argument. It also works without an authentication token, but in a more limited capacity.
>>> import ipinfo >>> handler = ipinfo.getHandler(access_token='123456789abc')
handler.getDetails() will return a Details object that contains all fields listed in the IPinfo developer docs with a few minor additions. Properties can be accessed directly.
>>> details.hostname 'any-in-2415.1e100.net'
details.country_name will return the country name, as supplied by the countries.json file. See below for instructions on changing that file for use with non-English languages. details.country will still return a country code.
>>> details.country 'US' >>> details.country_name 'United States'
details.latitude and details.longitude will return latitude and longitude, respectively, as strings. details.loc will still return a composite string of both values.
>>> details.loc '37.3861,-122.0840' >>> details.latitude '37.3861' >>> details.longitude '-122.0840'
details.all will return all details data as a dictionary.
>>> import pprint >>> pprint.pprint(details.all) {'abuse': {'address': 'US, CA, Mountain View, 1600 Amphitheatre Parkway, 94043', 'country': 'US', 'email': 'network-abuse@google.com', 'name': 'Abuse', 'network': '216.239.32.0/19', 'phone': '+1-650-253-0000'}, 'asn': {'asn': 'AS15169', 'domain': 'google.com', 'name': 'Google LLC', 'route': '216.239.36.0/24', 'type': 'business'}, 'city': 'Mountain View', 'company': {'domain': 'google.com', 'name': 'Google LLC', 'type': 'business'}, 'country': 'US', 'country_name': 'United States', 'hosting': {'host': 'google', 'id': 'GOOGLE', 'name': 'Google LLC', 'network': '216.239.32.0/19'}, 'hostname': 'any-in-2415.1e100.net', 'ip': '216.239.36.21', 'latitude': '37.3861', 'loc': '37.3861,-122.0840', 'longitude': '-122.0840', 'postal': '94035', 'region': 'California', 'timezone': 'America/Los_Angeles'}
The library gives the possibility to use the Lite API too, authentication with your token is still required.
The returned details are slightly different from the Core API.
>>> import ipinfo >>> handler = ipinfo.getHandlerLite(access_token='123456789abc') >>> details = handler.getDetails("8.8.8.8") >>> details.country_code 'US' >>> details.country 'United States'
The library also supports the Core API, which provides city-level geolocation with nested geo and AS objects. Authentication with your token is required.
>>> import ipinfo >>> handler = ipinfo.getHandlerCore(access_token='123456789abc') >>> details = handler.getDetails("8.8.8.8") >>> details.ip '8.8.8.8' >>> details.geo {'city': 'Mountain View', 'region': 'California', 'region_code': 'CA', 'country': 'United States', 'country_code': 'US', ...} >>> details.all['as'] {'asn': 'AS15169', 'name': 'Google LLC', 'domain': 'google.com', 'type': 'hosting', ...}
An asynchronous handler is also available:
>>> handler = ipinfo.getHandlerAsyncCore(access_token='123456789abc') >>> details = await handler.getDetails("8.8.8.8")
The library also supports the Plus API, which provides enhanced data including mobile carrier info and privacy detection. Authentication with your token is required.
>>> import ipinfo >>> handler = ipinfo.getHandlerPlus(access_token='123456789abc') >>> details = handler.getDetails("8.8.8.8") >>> details.ip '8.8.8.8' >>> details.geo {'city': 'Mountain View', 'region': 'California', 'region_code': 'CA', 'country': 'United States', 'country_code': 'US', ...} >>> details.mobile {'carrier': ..., 'mcc': ..., 'mnc': ...} >>> details.anonymous {'is_proxy': False, 'is_relay': False, 'is_tor': False, ...}
An asynchronous handler is also available:
>>> handler = ipinfo.getHandlerAsyncPlus(access_token='123456789abc') >>> details = await handler.getDetails("8.8.8.8")
The library also supports the Residential Proxy API, which allows you to check if an IP address is a residential proxy. Authentication with your token is required.
>>> import ipinfo >>> handler = ipinfo.getHandler(access_token='123456789abc') >>> details = handler.getResproxy("175.107.211.204") >>> details.ip '175.107.211.204' >>> details.last_seen '2025-01-20' >>> details.percent_days_seen 0.85 >>> details.service 'Bright Data'
An asynchronous handler is also available:
>>> handler = ipinfo.getHandlerAsync(access_token='123456789abc') >>> details = await handler.getResproxy("175.107.211.204")
In-memory caching of details data is provided by default via the cachetools library. This uses an LRU (least recently used) cache with a TTL (time to live) by default. This means that values will be cached for the specified duration; if the cache's max size is reached, cache values will be invalidated as necessary, starting with the oldest cached value.
Cache behavior can be modified by setting the cache_options keyword argument. cache_options is a dictionary in which the keys are keyword arguments specified in the cachetools library. The nesting of keyword arguments is to prevent name collisions between this library and its dependencies.
>>> import ipinfo >>> handler = ipinfo.getHandler(cache_options={'ttl':30, 'maxsize': 128})
It's possible to use a custom cache by creating a child class of the CacheInterface class and passing this into the handler object with the cache keyword argument. FYI this is known as the Strategy Pattern.
import ipinfo from ipinfo.cache.interface import CacheInterface class MyCustomCache(CacheInterface): ... handler = ipinfo.getHandler(cache=MyCustomCache())
You can access/update the cache directly via dictionary-like notation.
>>> import ipinfo >>> from ipinfo.handler_utils import cache_key >>> >>> access_token = '123456789abc' >>> handler = ipinfo.getHandler(access_token) >>> ip_cache_key = cache_key('1.1.1.1') # Check if IP is in the cache. >>> ip_cache_key in handler.cache True # Get the IP's details from cache. >>> handler.cache[ip_cache_key] {'ip': '1.1.1.1', 'hostname': 'one.one.one.one', 'anycast': True, 'city': 'Miami', 'region': 'Florida', 'country': 'US', 'loc': '25.7867,-80.1800', 'org': 'AS13335 Cloudflare, Inc.', 'postal': '33132', 'timezone': 'America/New_York', 'country_name': 'United States', 'latitude': '25.7867', 'longitude': '-80.1800'} # Set the IP's details to something else in the cache. >>> handler.cache[ip_cache_key] = None # Delete the IP from the cache. >>> del handler.cache[ip_cache_key]
Note: the asynchronous handler currently only accepts the timeout option,
input the same way as shown below.
Request behavior can be modified by setting the request_options keyword argument. request_options is a dictionary in which the keys are keyword arguments specified in the requests library. The nesting of keyword arguments is to prevent name collisions between this library and its dependencies.
>>> handler = ipinfo.getHandler(request_options={'timeout': 4})
You can add custom headers or modify default headers by setting the headers keyword argument when initializing the handler. headers is a dictionary of {'header': 'value'} format.
>>> handler = ipinfo.getHandler(headers={'user-agent': 'My Custom User-agent', 'custom_header': 'yes'})
When looking up an IP address, the response object includes details.country_name, details.isEU, details.country_flag, details.country_flag_url and details.country_currency attributes which includes the country based on American English. It is possible to return the country name in other languages by setting the countries, remove or add EU countries by setting the keyword argument eu_countries, change the country flag emoji or unicode by setting the keyword argument countries_flags or change country's currency code or currency symbol by setting the countries_currencies when creating the IPinfo object. Moreover, the response object includes a details.continent which includes continent code and name of IP. The default file can be changed by setting the continent while creating the IPinfo object.
>>> import ipinfo # Country Names: In-memory map >>> countries = { "BD": "Bangladesh", "BE": "Belgium", "BF": "Burkina Faso", ... } # EU Countries: In-memory list >>> eu_countries = [ "IE", "AT", "LT", ... ] # Country Flags: In-memory map >>> countries_flags = { "AD": {"emoji": "🇦🇩", "unicode": "U+1F1E6 U+1F1E9"}, "AE": {"emoji": "🇦🇪", "unicode": "U+1F1E6 U+1F1EA"}, "AF": {"emoji": "🇦🇫", "unicode": "U+1F1E6 U+1F1EB"}, ... } # Country Currencies: In-memory map >>> countries_currencies = { "AD": {"code": "EUR", "symbol": "€"}, "AE": {"code": "AED", "symbol": "د.إ"}, "AF": {"code": "AFN", "symbol": "؋"}, ... } # Continents: In-memory map >>> continents = { "BD": {"code": "AS", "name": "Asia"}, "BE": {"code": "EU", "name": "Europe"}, "BF": {"code": "AF", "name": "Africa"}, ... } # create handler >>> access_token = '123456789abc' >>> handler = ipinfo.getHandler( access_token, countries=countries, eu_countries=eu_countries, countries_flags=countries_flags, countries_currencies=countries_currencies, continents=continents )
Looking up a single IP at a time can be slow. It could be done concurrently from the client side, but IPinfo supports a batch endpoint to allow you to group together IPs and let us handle retrieving details for them in bulk for you.
>>> import ipinfo, pprint >>> access_token = '123456789abc' >>> handler = ipinfo.getHandler(access_token) >>> pprint.pprint(handler.getBatchDetails([ ... '1.1.1.1', ... '8.8.8.8', ... '1.2.3.4/country', ... ])) {'1.1.1.1': {'city': '', 'country': 'AU', 'country_name': 'Australia', 'hostname': 'one.one.one.one', 'ip': '1.1.1.1', 'latitude': '-33.4940', 'loc': '-33.4940,143.2100', 'longitude': '143.2100', 'org': 'AS13335 Cloudflare, Inc.', 'region': ''}, '1.2.3.4/country': 'US', '8.8.8.8': {'city': 'Mountain View', 'country': 'US', 'country_name': 'United States', 'hostname': 'dns.google', 'ip': '8.8.8.8', 'latitude': '37.3860', 'loc': '37.3860,-122.0838', 'longitude': '-122.0838', 'org': 'AS15169 Google LLC', 'postal': '94035', 'region': 'California', 'timezone': 'America/Los_Angeles'}}
The input size is not limited, as the interface will chunk operations for you behind the scenes.
Please see the official documentation for more information and limitations.
There are official IPinfo client libraries available for many languages including PHP, Go, Java, Ruby, and many popular frameworks such as Django, Rails, and Laravel. There are also many third-party libraries and integrations available for our API.
Founded in 2013, IPinfo prides itself on being the most reliable, accurate, and in-depth source of IP address data available anywhere. We process terabytes of data to produce our custom IP geolocation, company, carrier, VPN detection, hosted domains, and IP type data sets. Our API handles over 40 billion requests a month for 100,000 businesses and developers.
ipinfo/python is a public repo on GitHub by ipinfo. Official Python Library for IPinfo API (IP geolocation and other types of IP data).
It declares the Apache-2.0 license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-10-21. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Comfortably monitor your network traffic 🕵️♂️
The best IP Toolbox. Check your IP address & geolocation, test IP for WebRTC and DNS IP leaks, run an IP quality check, browser fingerprint check, website availability check, network speed test, global latency test, MTR test, Whois search, and more.


A SOCKS proxy written in Python that randomizes your source IP address. Round-robin your evil packets through SSH tunnels or give them billions of unique source addresses!

Official Command Line Interface for the IPinfo API (IP geolocation and other types of IP data)
Official PHP library for IPinfo (IP geolocation and other types of IP data)
Official Laravel client library for IPinfo API (IP geolocation and other types of IP data)
Official Node client library for IPinfo API (IP geolocation and other types of IP data)
mmdbctl is an MMDB file management CLI supporting various operations on MMDB database files.
Go library for IPinfo API (IP geolocation and other types of IP data)
This page is also available as structured data, with the same sources and dates.
/api/v1/resources/gh/ipinfo/pythonTake My Repo has not tested this on your machine. Requirements come from the project's own documentation.