The MaxMind DB API

The MaxMind DB  provides a pure Python and C extension for reading MaxMind GeoIP2 databases, Web services and data from the libmaxminddb binary file format. Compared to the previous GeoIP2 databases, MaxMind DB offers improved performance with an average of 4–6 times faster lookups.

This module allows you to easily integrate MaxMind IP geolocation in your application by using a simple mmdblookup command. The results of the lookup are returned in a list and can be used as an input for any other Python function that takes string parameters and returns an output.

The names property contains information about the names associated with each record in the maxmind database. The names property also provides a default value that may be used as an input for functions which take a tuple of map keys and 0-based array indexes separated by /.

MaxMind Database: Harnessing Geolocation Data for Insights

names also contains information about the location of each IP address. This includes the metropolitan code if the IP address is in the United States (only available for the Country, City Plus, Insights, and Enterprise databases). In addition, a tuple of data records that describe the country and its subdivisions is included. The names data is mapped to a tuple of geographic features in the Insights database that have a name, such as a city or region, associated with them.

The ip attribute contains the IP address of the client. Depending on the database version, this may include the IPv4 or IPv6 network prefix length. In addition, this attribute can also include a flag indicating whether the client is using an anycast network (only available for the Enterprise database). This feature may be useful for multi-sided platforms that need to identify and match users with other users on their platform.