GeoIP Legacy Web Services

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

Release Notes

Changes to the GeoIP web services are documented in our release notes.

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:

Service URI
Country https://geoip.maxmind.com/a
City https://geoip.maxmind.com/b
City/ISP/Org https://geoip.maxmind.com/f
Insights (formerly Omni) https://geoip.maxmind.com/e

The geoip.maxmind.com hostname automatically picks the data center geographically closest to you. In some cases, this data center may not be the one that provides you with the best service. You can explicitly try the geoip-us-east.maxmind.com and geoip-us-west.maxmind.com hostnames to see which one provides the best performance for you.

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. See our list of cities to see all the possible return values. This list is updated on a regular basis.
Region code string (2)

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

For the US and Canada, we return an ISO-3166-2 code. In addition to the standard ISO codes, we may also return one of the following:

  • AA – Armed Forces America
  • AE – Armed Forces Europe
  • AP – Armed Forces Pacific

We return a FIPS code for all other countries.

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 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. MaxMind returns the same metro codes as the Google AdWords API.
Area code string The telephone area code associated with the IP address. These are only available for IP addresses in the US. This output is deprecated, and 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:

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
  • AS – Asia
  • EU – Europe
  • NA – North America
  • OC – Oceania
  • SA – South America
Latitude decimal The latitude associated with the IP address. The latitude and longitude are near the center of the most granular location value returned: postal code, city, region, or country.
Longitude decimal The longitude associated with the IP address.
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:

  • 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.