
Is provided, the address that the web service is called from will Ip_address – IPv4 or IPv6 address as a string. country ( ip_address: Union = 'me' ) → ¶Ĭall the GeoIP2 Country endpoint with the specified IP. This will close the session and any associated connections. If noĪddress is provided, the address that the web service is It may optionally includeĪ basic auth username and password, ( ip_address: Union = 'me' ) → ¶Ĭall City endpoint with the specified IP.

Note that the only locale which is always present in the GeoIP2ĭata is “en”. The name in the first locale that has one. Multiple names (country, city, etc.), its name property will return Passed on to record classes to use when their name properties are To use the GeoLite2 web service instead of GeoIP2

The following keyword arguments are also accepted: Parameters:
#Maxmind db reader license#

enterprise method to do a lookup in the Enterprise database > response = reader. Reader ( '/path/to/GeoIP2-Enterprise.mmdb' ) as reader : > # Use the. You should use the same object > # across multiple requests as creation of it is expensive. > import geoip2.database > # This creates a Reader object. Please > # note that Insights is not supported by the GeoLite2 web service. AsyncClient ( 42, 'license_key' ) as client : > # Replace "city" with the method corresponding to the web service > # that you are using, i.e., "country", "city", or "insights". Set the "host" keyword argument to "" to use the > # GeoLite2 web service instead of GeoIP2 Precision. > # > # Replace "42" with your account ID and "license_key" with your license > # key. If you are using multiple event > # loops, you must ensure the object is not used on another loop.

> import asyncio > import geoip2.webservice > async def main (): > # This creates an AsyncClient object that can be reused across > # requests on the running event loop. Client ( 42, 'license_key' ) as client : > # Replace "city" with the method corresponding to the web service > # that you are using, i.e., "country", "city", or "insights". > # Replace "42" with your account ID and "license_key" with your license > # key. import geoip2.webservice > # This creates a Client object that can be reused across requests.
