GeoIP Legacy JavaScript

Note: On October 31, 2017, we will discontinue our legacy GeoIP JavaScript services, which use the endpoints and

Please upgrade your legacy GeoIP integration to use our GeoIP2 JavaScript Client API before that date. See here for more information about what to do.

Note: This documentation is for the GeoIP Legacy JavaScript services. New customers do not have access to these services. Please use the GeoIP2 JavaScript.

MaxMind offers an API which returns JavaScript code for the client's IP address. This comes in two flavors, city and country.

You can include the JavaScript provided by MaxMind in your web pages. This script creates several window-global functions that return information about the client's IP address.

Service Plans

To purchase queries for use with the API, please visit our web services order page.


All domains using the service must be registered. New users may purchase GeoIP2 Precision service queries and receive an account to register domains. Existing account holders are able to register domains directly.

Per-Service URIs

The URIs for each service are as follows:

Service URI <script> tag
Country <script src="//" type="text/javascript"></script>
City <script src="//" type="text/javascript" ></script>

The use of the charset attribute in the script tag should cause modern browsers to decode the content of the JavaScript script so that it matches the encoding of the web page.

Unlike some of our other web services, the JavaScript service only has one hostname.


Both of these services create a set of global functions, each of which returns a single item of information about the client's IP. Note that some functions may return an empty string. This happens if we do not have that piece of information for a given IP. If the IP address is a private IP address or not in our database at all, all of the functions will return an empty string.

Included in …
Function Name Type (length) Description Country? City? Your IP
geoip_city() 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.
geoip_region() 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.

geoip_region_name() string The region name associated with the IP address.
geoip_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.
geoip_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.

geoip_country_name() string The country name associated with the IP address.
geoip_latitude() decimal An approximate latitude of the location associated with the network.
geoip_longitude() decimal An approximate longitude of the location associated with the IP address. 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.

Error Codes

This service returns an HTTP status code if there is an error.

HTTP Status Code Reason
400 Bad Request This code is returned if the requesting IP address is not found in our database.
401 Unauthorized The referring domain has not been registered.
403 Forbidden

You do not have permission to use the service. Please contact for more information.