GeoIP Legacy Web Services

We are retiring our GeoIP Legacy database formats at the end of May 2022. Please see our blog post for more information, including how to migrate to GeoIP2.

Note: This documentation is for the GeoIP legacy services. New customers do not have access to these services. Please use the GeoIP2 Precision Web Services.

The GeoIP web services allow you to look up information about a given IP address using an HTTP-based API.

IP Geolocation Usage

IP geolocation is inherently imprecise. Locations are often near the center of the population. Any location provided by a GeoIP database should not be used to identify a particular address or household.

HTTP-based API

The HTTP API requires you to pass a set of parameters as an HTTP GET or POST. Results are returned in a simple text format documented below.

We offer several different services, each providing a different amount of information about the IP address.

All of the services take the same parameters as inputs. The only difference between them is the URI they use and the data they return. The two parameters that each service takes are the IP address to look up and your MaxMind license key.

The parameters should be passed in a query string or as a form post (application/x-www-form-urlencoded). The IP address parameter should be named i (lower case "I") and the license key should be named l (lower case "L").

The IP address should be passed as a string like "44.55.66.77" or "2001:db8::2:1".

Per-Service URIs

The URIs for each service are as follows:

The geoip.maxmind.com hostname automatically picks the data center geographically closest to you.

Security

We require TLS 1.2 or greater for HTTPS requests to our servers to keep your data secure. We also recommend you access this service via HTTPS.

Output

All services return data as a set of comma-separated fields. The ISP name, Organization name, and AS number fields are quoted, since they may contain a comma. The other fields are not escaped or quoted, but they will never contain a comma.

All strings are returned in the ISO-8859-1 encoding. This encoding is also referred to as latin1.

Included in …

Name

Type (length)

Description

Country?

City?

City/ISP/Org?

Insights (formerly Omni)?

Accuracy radius

integer

The radius in kilometers around the specified location where the IP address is likely to be.

City name

string

The city or town name associated with the IP address.

Region code

string (2)

A two character ISO-3166-2 code for the state/region associated with the IP address.

We previously returned a FIPS 10-4 code for all countries other than the United States and Canada. See our blog post detailing changes to our legacy web services.

For customers who have not yet updated their integration to reflect the changes detailed in the above blog post, we provide a CSV file which maps our region codes to region names. The columns are ISO country code, region code (FIPS or ISO), and the region name.

Region name

string

The region name associated with the IP address.

Postal code

string

The postal code associated with the IP address. These are available for some IP addresses in Australia, Canada, France, Germany, Italy, Spain, Switzerland, United Kingdom, and the US. We return the first 3 characters for Canadian postal codes. We return the first 2-4 characters (outward code) for postal codes in the United Kingdom.

Metro code

integer

The metro code associated with the IP address. These are only available for IP addresses in the US.

Area code

string

Deprecated. This field will be empty in the updated legacy web service. See our blog post detailing changes to our legacy web services.

For customers who have not yet updated their integration to reflect the changes detailed in the above blog post, this field will be the telephone area code associated with the IP address. These are only available for IP addresses in the US. This output may not reflect newer area codes.

Country code

string (2)

A two-character ISO 3166-1 country code for the country associated with the IP address. In addition to the standard codes, we may also return one of the following:

  • A1 – an anonymous proxy.

  • A2 – a satellite provider.

  • EU – an IP in a block used by multiple European countries.

  • AP – an IP in a block used by multiple Asia/Pacific region countries.

The US country code is returned for IP addresses associated with overseas US military bases.

Country name

string

The country name associated with the IP address.

Continent code

string (2)

A two-character code for the continent associated with the IP address. The possible codes are:

  • AF – Africa

  • AN – Antarctica

  • AS – Asia

  • EU – Europe

  • NA – North America

  • OC – Oceania

  • SA – South America

Latitude

decimal

The approximate latitude of the location associated with the network. This value is not precise and should not be used to identify a particular address or household

Longitude

decimal

The approximate longitude of the location associated with the network. Latitude and Longitude are often near the center of population. These values are not precise and should not be used to identify a particular address or household.

Time zone

string

The time zone associated with the IP address. Time zone names are taken from the IANA time zone database. See the list of possible values.

AS number

string

The autonomous system number associated with the IP address.

User type

enum

The user type associated with the IP address. This will be one of the following values.

  • business

  • cafe

  • cellular

  • college

  • contentDeliveryNetwork

  • government

  • hosting

  • library

  • military

  • residential

  • router

  • school

  • searchEngineSpider

  • traveler

Netspeed

enum

The network speed associated with the IP address. This can be one of the following values:

  • Dialup

  • Cable/DSL

  • Corporate

  • Cellular

Domain

string

The second level domain associated with the IP address. This will be

something like "example.com" or "example.co.uk", not "foo.example.com".

ISP name

string

The name of the ISP associated with the IP address.

Organization name

string

The name of the organization associated with the IP address.

City confidence factor

string

A value from 0-100 representing our confidence that the city is correct.

Region confidence factor

string

A value from 0-100 representing our confidence that the region is correct.

Postal confidence factor

string

A value from 0-100 representing our confidence that the postal code is correct.

Country confidence factor

string

A value from 0-100 representing our confidence that the country is correct.

Error code

string

If there was an error or warning with this request, this field contains an error code string.

The possible error codes are:

  • PERMISSION_REQUIRED – This is returned if you do not have permission to use the service. Please contact support@maxmind.com for more information.

  • INVALID_LICENSE_KEY – This error will be returned when the license key you pass is not a valid license key or when your account has run out of queries.

  • LICENSE_REQUIRED – The Insight service returns this instead of INVALID_LICENSE_KEY.

  • IP_NOT_FOUND – This error will be returned if the IP address it not valid, if it is not public, or if it is not in our GeoIP database. It will also be returned if you do not pass an IP address at all.

Output field order

Since all output is returned as a comma separated string, the order in which fields are returned must be known in order to parse the result. If the request is successful, the error field may be omitted entirely, since it always comes last.

Service

Field Order

Country

  • Country code

  • Error

City

  • Country code

  • Region code

  • City name

  • Latitude

  • Longitude

  • Error

City/ISP/Org

  • Country code

  • Region code

  • City name

  • Postal code

  • Latitude

  • Longitude

  • Metro code

  • Area code

  • ISP name

  • Organization name

  • Error

Insights

  • Country code

  • Country name

  • Region code

  • Region name

  • City name

  • Latitude

  • Longitude

  • Metro code

  • Area code

  • Time zone

  • Continent code

  • Postal code

  • ISP name

  • Organization name

  • Domain

  • AS number

  • Netspeed

  • User type

  • Accuracy radius

  • Country confidence factor

  • City confidence factor

  • Region confidence factor

  • Postal confidence factor

  • Error

Client Code Examples

The examples below are all for the Insights or City/ISP/Org web services. Client code for other services will be very similar. The only differences are the URI path and the fields which are returned.

Perl

This is an example for the Insights web service.

PHP

This is an example for the Insights web service.

Python 2

This is an example for the Insights web service.

Python 3

This is an example for the Insights web service.

Ruby 1.9

This is an example for the Insights web service.

Java

This is an example for the Insights web service.

C#

This is an example for the Insights web service.

VB.Net

This is an example for the City/ISP/Org web service.

Cold Fusion

This is an example for the City/ISP/Org web service.

ASP

This is an example for the City/ISP/Org web service.

VBScript

This is an example for the City/ISP/Org web service.

This page was last updated on December 6, 2021.