Geolocation request and response

  • The Google Geolocation API returns a location and accuracy radius based on cell tower and WiFi access point data sent in a POST request.

  • Request bodies are formatted in JSON and should includecellTowers andwifiAccessPoints arrays with relevant signal data for optimal results.

  • Locally administered MAC addresses and reserved IANA ranges for WiFi access points should be filtered out to improve the success rate of API calls.

  • cellId andnewRadioCellId fields are used to identify cell towers with specific calculation methods based on radio type.

  • Successful responses provide latitude and longitude coordinates within alocation object, along with anaccuracy value representing the radius of uncertainty in meters.

Geolocation requests

Geolocation requests are sent using POST to the following URL:

https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY

You must specify a key in your request, included as the value of akey parameter. Akey is your application's API key. This key identifies your application for purposes of quota management. Learn how toget a key.

Request body

The request body must be formatted as JSON. If the request body is not included, the resultsare returned based on the IP address of request location. The following fields aresupported, and all fields are optional, unless otherwise stated:

FieldJSON typeDescriptionNotes
homeMobileCountryCodenumber (uint32)The mobile country code (MCC) for the device'shome network.Supported forradioTypegsm (default),wcdma,lte andnr; not used forcdma.
Valid range: 0–999.
homeMobileNetworkCodenumber (uint32)The Mobile Network Code for the device'shome network. This is the MNC for GSM, WCDMA, LTE and NR.
CDMA uses the System ID (SID)
Valid range for MNC: 0–999.
Valid range for SID: 0–32767.
radioTypestringThe mobile radio type. Supported values aregsm,cdma,wcdma,lte andnr.While this field is optional, itshould always be included if the radio type is known by the client.
If the field is omitted, Geolocation API defaults togsm, whichwill result in invalid or zero results if the assumed radio type is incorrect.
carrierstringThe carrier name.
considerIpbooleanSpecifies whether to fall back to IP geolocation if WiFi and cell tower signals are missing, empty, or not sufficient to estimate device location.Defaults totrue. SetconsiderIp tofalse to prevent fall back.
cellTowersarrayAn array of cell tower objects.See theCell Tower Objects section below.
wifiAccessPointsarrayAn array of WiFi access point objects.See theWiFi Access Point Objects section below.

An example Geolocation API request body is shown below.

{"homeMobileCountryCode":310,"homeMobileNetworkCode":410,"radioType":"lte","carrier":"Vodafone","considerIp":true,"cellTowers":[// See theCell Tower Objects section below.],"wifiAccessPoints":[// See theWiFi Access Point Objects section below.]}

Cell tower objects

The request body'scellTowers array contains zero or more cell tower objects.

FieldJSON typeDescriptionNotes
cellIdnumber (uint32)Unique identifier of the cell.Required forradioTypegsm (default),cdma,wcdma andlte;rejected fornr.
See theCalculating cellId section below, which also lists the valid value ranges for each radio type.
newRadioCellIdnumber (uint64)Unique identifier of the NR (5G) cell.Required forradioTypenr;rejected for other types.
See theCalculating newRadioCellId section below, which also lists the valid value range for the field.
locationAreaCodenumber (uint32)The Location Area Code (LAC) for GSM and WCDMA networks.
The Network ID (NID) for CDMA networks.
The Tracking Area Code (TAC) for LTE and NR networks.
Required forradioTypegsm (default) andcdma, optional for other values.
Valid range withgsm,cdma,wcdma andlte: 0–65535.
Valid range withnr: 0–16777215.
mobileCountryCodenumber (uint32)The cell tower's Mobile Country Code (MCC).Required forradioTypegsm (default),wcdma,lte andnr; not used forcdma.
Valid range: 0–999.
mobileNetworkCodenumber (uint32)The cell tower's Mobile Network Code. This is the MNC for GSM, WCDMA, LTE and NR.
CDMA uses the System ID (SID).
Required.
Valid range for MNC: 0–999.
Valid range for SID: 0–32767.

The following optional fields are not used, but may be included if values are available.

FieldJSON typeDescriptionNotes
agenumber (uint32)The number of milliseconds since this cell was primary.If age is 0, thecellId ornewRadioCellId represents a current measurement.
signalStrengthnumber (double)Radio signal strength measured in dBm.
timingAdvancenumber (double)Thetiming advance value.

CalculatingcellId

Radio types prior to NR (5G) use the 32-bitcellId field for passing the network cell ID to Geolocation API.

  • GSM (2G) networks use the 16-bit Cell ID (CID) as is. Valid range: 0–65535.
  • CDMA (2G) networks use the 16-bit Base Station ID (BID) as is. Valid range: 0–65535.
  • WCDMA (3G) networks use the UTRAN/GERAN Cell Identity (UC-ID), which is a 28-bit integer value concatenating the 12-bit Radio Network Controller Identifier (RNC-ID) and 16-bit Cell ID (CID).
    Formula:rnc_id << 16 | cid.
    Valid range: 0–268435455.
    Note: Specifying only the 16-bit Cell ID value in WCDMA networks results in incorrect or zero results.
  • LTE (4G) networks use the E-UTRAN Cell Identity (ECI), which is a 28-bit integer value concatenating the 20-bit E-UTRAN Node B Identifier (eNBId) and the 8-bit Cell ID (CID).
    Formula:enb_id << 8 | cid.
    Valid range: 0–268435455.
    Note: Specifying only the 8-bit Cell ID value in LTE networks results in incorrect or zero results.

Placing values outside these ranges in the API request may result in undefined behavior. The API, at Google's discretion, may truncate the number so it fits in the documented range, infer a correction to theradioType, or return aNOT_FOUND result without any indicator in the response.

An example LTE cell tower object, which is part of therequest body, is below.

{..."cellTowers":[{"cellId":170402199,"locationAreaCode":35632,"mobileCountryCode":310,"mobileNetworkCode":410,"age":0,"signalStrength":-60,"timingAdvance":15}]}

The response for the preceding request looks like this:

{"location":{"lat":37.7801129,"lng":-122.4168229},"accuracy":180.052}

CalculatingnewRadioCellId

Newer networks, whose cell IDs are longer than 32 bits use the 64-bitnewRadioCellId field for passing the network cell ID to Geolocation API.

  • NR (5G) networks use the 36-bit New Radio Cell Identity (NCI) as is.
    Valid range: 0–68719476735.

An example NR cell tower object, which is part of therequest body, is below.

{..."cellTowers":[{"newRadioCellId":68719476735,"mobileCountryCode":310,"mobileNetworkCode":410,"age":0,"signalStrength":-60,}]}

The response to the preceding request looks like this:

{"location":{"lat":37.7646157,"lng":-122.4127361},"accuracy":1458.5570522410717}

WiFi access point objects

The request body'swifiAccessPoints array must contain two or more WiFi access point objects representingphysically distinct stationary access point devices. ThemacAddress field is required. All other fields are optional. The service ignores access points that move, such as those in airplanes and trains.

FieldJSON typeDescriptionNotes
macAddressstringThe MAC address of the WiFi node. It's typically called a BSS, BSSID or MAC address.Required.Colon-separated (:) hexadecimal string.
Onlyuniversally-administered MAC addresses can be located using the API. Other MAC addresses are silently dropped and may lead to an API request becoming effectively empty. For details, seeDropping useless Wifi access points.
signalStrengthnumber (double)The current signal strength measured in dBm.For WiFi access points, dBm values are typically -35 or lower and range from -128 to -10 dBm. Be sure to include the minus sign.
For values greater than -10 dBm, the API returnsNOT FOUND.
agenumber (uint32)The number of milliseconds since this access point was detected.
channelnumber (uint32)The channel over which the client is communicating with the access point.
signalToNoiseRationumber (double)The current signal to noise ratio measured in dB.

An example WiFi access point object, which is part of therequest body, isshown below.

{..."macAddress":"f0:d5:bf:fd:12:ae","signalStrength":-43,"signalToNoiseRatio":0,"channel":11,"age":0}

The response for the preceding request looks like this:

{"location":{"lat":37.7801129,"lng":-122.4168229},"accuracy":180.052}

Sample requests

Note: MAC addresses can change over time. For that reason, the examples on this page may result in an error message from the API.

If you'd like to try the Geolocation API with sample data, save the following JSON to a file:

{"considerIp":"false","wifiAccessPoints":[{"macAddress":"3c:37:86:5d:75:d4","signalStrength":-35,"signalToNoiseRatio":0},{"macAddress":"30:86:2d:c4:29:d0","signalStrength":-35,"signalToNoiseRatio":0}]}

You can then usecurl to make your request from the command line:

$ curl -d @your_filename.json -H "Content-Type: application/json" -i "https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY"

The response for the preceding MAC addresses looks like this:

{"location":{"lat":37.4241173,"lng":-122.0915717},"accuracy":20}

Dropping unused WiFi access points

Removing WiFi access point objects withmacAddresses that arelocally-administered can improve the success rate of Geolocation API calls that use WiFi as input. If, after filtering, it can be determined that a Geolocation API call wouldn't succeed, mitigations such as using older location signals or WiFi APs with weaker signals can be used. This approach is a tradeoff between your application's need for a location estimate and its precision and recall requirements. The following filtering techniques demonstrate how to filter the inputs, but don't show the mitigations that you may, as the application engineer, choose to apply.

Locally administered MAC addresses are not useful location signals for the API and are silently dropped from requests. You can remove such MAC addresses by ensuring that the second least-significant bit of themacAddress's most-significant byte is0, e.g. the1 bit represented by the2 in02:00:00:00:00:00. The broadcast MAC address (FF:FF:FF:FF:FF:FF) is an example of a MAC address that would be usefully excluded by this filter.

The range of MAC addresses between00:00:5E:00:00:00 and00:00:5E:FF:FF:FF arereserved for IANA and often used for network management and multicast functions which precludes their use as a location signal. You should also remove these MAC addresses from inputs to the API.

For example, usable MAC addresses for Geolocation can be gathered from an array ofmacAddress strings namedmacs:

Java
String[]macs={"12:34:56:78:9a:bc","1c:34:56:78:9a:bc","00:00:5e:00:00:01"};ArrayList<String>_macs=newArrayList<>(Arrays.asList(macs));_macs.removeIf(m->!(0==(2 &Integer.parseInt(m.substring(1,2),16))                      &&!m.substring(0,8).toUpperCase().equals("00:00:5E")));
Python
macs=['12:34:56:78:9a:bc','1c:34:56:78:9a:bc','00:00:5e:00:00:01']macs=[mforminmacsif(0==(2 &int(m[1],16))andm[:8].upper()!='00:00:5E')]
JavaScript
macs=['12:34:56:78:9a:bc','1c:34:56:78:9a:bc','00:00:5e:00:00:01'];macs=macs.filter(m=>0===(2 &Number.parseInt(m[1],16))                           &&m.substr(0,8).toUpperCase()!=='00:00:5E');

Using this filter results in only1c:34:56:78:9a:bcremaining in the list. Because this list hasfewer than 2 WiFi MAC addresses, therequest wouldn't be successful and an HTTP 404(notFound)response would be returned.

Geolocation responses

A successful geolocation request returns a JSON-formatted response defining a location and radius.

  • location: The user's estimated latitude and longitude coordinates, in degrees. Contains onelat and onelng subfield.
  • accuracy: The accuracy of the estimated location, in meters. This represents the radius of a circle around the givenlocation.
{"location":{"lat":37.421875199999995,"lng":-122.0851173},"accuracy":120}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.