NAV Navbar
shell php python javascript

Endpoints

API requests can be sent to any of the following endpoints. Developers can choose the endpoint that’s geographically closer to their servers for minimal latency.

Region 1: US East (Northern Virginia)
https://us1.unwiredlabs.com/v2/<specific_api_endpoint>

Region 2: US West (San Francisco)
https://us2.unwiredlabs.com/v2/<specific_api_endpoint>

Region 3: Europe (France)
https://eu1.unwiredlabs.com/v2/<specific_api_endpoint>

Region 4: Asia Pacific (Singapore)
https://ap1.unwiredlabs.com/v2/<specific_api_endpoint>

Geolocation

The Geolocation API helps developers locate IoT, M2M and other connected devices anywhere in the world without GPS. The device first sends the API data about which Cellular networks and WiFi networks it can see nearby. The API then uses Unwired Labs’ large datasets of Cell towers, WiFi networks backed by numerous algorithms to calculate and return the device’s location.

Usage

curl --request POST \
  --url https://us1.unwiredlabs.com/v2/process.php \
  --data '{"token": "your_API_token","radio": "gsm","mcc": 310,"mnc": 410,"cells": [{"lac": 7033,"cid": 17811}],"wifi": [{"bssid": "00:17:c5:cd:ca:aa","channel": 11,"frequency": 2412,"signal": -51}, {"bssid": "d8:97:ba:c2:f0:5a"}],"address": 1}'

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://us1.unwiredlabs.com/v2/process.php",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"token\": \"your_API_token\",\"radio\": \"gsm\",\"mcc\": 310,\"mnc\": 410,\"cells\": [{\"lac\": 7033,\"cid\": 17811}],\"wifi\": [{\"bssid\": \"00:17:c5:cd:ca:aa\",\"channel\": 11,\"frequency\": 2412,\"signal\": -51}, {\"bssid\": \"d8:97:ba:c2:f0:5a\"}],\"address\": 1}",
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

import requests

url = "https://us1.unwiredlabs.com/v2/process.php"

payload = "{\"token\": \"your_API_token\",\"radio\": \"gsm\",\"mcc\": 310,\"mnc\": 410,\"cells\": [{\"lac\": 7033,\"cid\": 17811}],\"wifi\": [{\"bssid\": \"00:17:c5:cd:ca:aa\",\"channel\": 11,\"frequency\": 2412,\"signal\": -51}, {\"bssid\": \"d8:97:ba:c2:f0:5a\"}],\"address\": 1}"
response = requests.request("POST", url, data=payload)

print(response.text)

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://us1.unwiredlabs.com/v2/process.php",
  "method": "POST",
  "headers": {},
  "processData": false,
  "data": "{\"token\": \"your_API_token\",\"radio\": \"gsm\",\"mcc\": 310,\"mnc\": 410,\"cells\": [{\"lac\": 7033,\"cid\": 17811}],\"wifi\": [{\"bssid\": \"00:17:c5:cd:ca:aa\",\"channel\": 11,\"frequency\": 2412,\"signal\": -51}, {\"bssid\": \"d8:97:ba:c2:f0:5a\"}],\"address\": 1}"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

POST requests can be sent to the following URL:

https://us1.unwiredlabs.com/v2/process.php

Replace us1 with an endpoint that’s closer to your location.

Sandbox

Use the sandbox to send sample Geolocation requests.

Request body

A sample request body

{
   "token":"your_API_token",
   "radio":"gsm",
   "mcc":310,
   "mnc":410,
   "cells":[
      {
         "lac":7033,
         "cid":17811
      }
   ],
   "wifi":[
      {
         "bssid":"00:17:c5:cd:ca:aa",
         "channel":11,
         "frequency":2412,
         "signal":-51
      },
      {
         "bssid":"d8:97:ba:c2:f0:5a"
      }
   ],
   "address":1
}

Send the following data as a POST request in the JSON format. Only the token parameter is mandatory. All others are optional.

Parameter Description Type          
token Your API token. If you don’t have one, get one free here! string
id ID of the device, in case you are in a per-device plan.
This could be any unique ID such as IMEI, IMSI, phone number, etc.,.
string
radio Radio type of the device. Supported values are ‘gsm’, ‘cdma’, ‘umts’ and ‘lte’. This field should be included for more accurate results. string
mcc Mobile Country Code of your operator’s network represented by an integer (Optional). Range: 0 to 999. A list of possible MCCs can be found here. integer
mnc Mobile Network Code of your operator’s network represented by an integer (Optional). Range: 0 to 999. On CDMA, provide the System ID or SID, with range: 1 to 32767. integer
cells An array of cell ID objects. Read more. array
wifi An array of WiFi objects visible to the device. Read more. array
address The physical address of the returned location. Read more integer
fallbacks An array of fallback options to enable or disable. Read more array
ip IP address of device. Read more string
bt Specify level of strictness to apply to Borders. Read more integer

Cells

GSM - GSM, EDGE, GPRS, 2G

Parameter Description Type Accepted
lac the Location Area Code of your operator’s network. integer 1 - 65533
cid Cell ID integer 0 - 65535
radio Radio type of the device string gsm
mcc Mobile Country Code of your operator’s network integer 0 - 999
mnc Mobile Network Code of your operator’s network represented by an integer integer 0 - 999
signal Signal Strength (RSSI) integer -113 - -51
asu Arbitrary Strength Unit integer 0 - 31
ta Timing Advance integer 0 - 63



CDMA - 1xRTT, CDMA, eHRPD, EVDO_0, EVDO_A, EVDO_B, IS95A, IS95B

Parameter Description Type Accepted
lac Network ID (NID) integer 1 - 65534
cid Base ID / Station ID integer 0 - 65535
radio Radio type of the device string cdma
mcc Mobile Country Code of your operator’s network integer 0 - 999
mnc System ID (SID) integer 1 - 32767
signal Signal Strength of the radio, measured in dBm integer -100 - -75
asu Arbitrary Strength Unit measured by the mobile phone integer 1 - 16



UMTS - UMTS, HSPA, HSDPA, HSPA+, HSUPA, WCDMA, 3G

Parameter Description Type Accepted
lac Location Area Code of your operator’s network. integer 1 - 65533
cid Cell ID integer 0 - 268435455
radio Radio type of the device string umts
mcc Mobile Country Code of your operator’s network. integer 0 - 999
mnc Mobile Network Code of your operator’s network. integer 0 - 999
signal Signal Strength (RSCP) of your operator’s network. integer -121 - -25
psc Primary Scrambling Code integer 0 - 511
asu Arbitrary Strength Unit measured by the mobile phone integer -5 - 91



LTE - LTE, 4G

Parameter Description Type Accepted Required
lac Tracking Area Code of your operator’s network. integer 1 - 65533 yes
cid Cell ID integer 0 - 268435455 yes
radio Radio type of the device string lte yes
mcc Mobile Country Code of your operator’s network. integer 0 - 999 yes
mnc Mobile Network Code of your operator’s network. integer 0 - 999 yes
signal Signal Strength (RSRP) of the radio, measured in dBm integer -113 - -51 recommended
psc Physical Cell ID on LTE integer 0 - 503 recommended
asu Arbitrary Strength Unit measured by the mobile phone integer 0 - 97
ta Timing Advance integer 0 - 63

WiFi

Parameter Description Type          
bssid Basic Service Set Identifier or MAC address of the Access Point. Typical format of a MAC address is xx-xx-xx-xx-xx-xx. However, the delimiter can be any of these when sent to the API: : or - or . string
channel Channel the WiFi network is operating in (optional) integer
frequency Frequency the WiFi network is operating in (MHz) (optional) integer
signal Signal Strength (RSSI) (optional) integer
signalToNoiseRatio The current signal to noise ratio, measured in dB (optional) integer

Fallbacks

Parameter Description Type           Accepted Default
all Enable or disable all fallbacks. integer 0 or 1 N/A
ipf Enable IP address fallback. Specify IP address of the device in the “ip” field if it’s different from the device making the API call. integer 0 or 1 0
lacf Enable LAC fallback. If we are unable to locate a cell,
we will return an approzimate location
based on nearby cells in our database.
integer 0 or 1 1
scf Enable Short CID fallback. Adds support for devices
that can only see 16-bit (short) CID
of an UMTS 28-bit UTRAN CID.
integer 0 or 1 1

Notes

Address

The physical address of the returned location. Pass a value of 1 (default) to return address, 2 to return address components - street, city, postcode, etc - separately and 0 to suppress it. If we do not have an address for a location, the API will return Not available.

Type Accepted Default
integer 0 or 1 or 2 1

Border Threshold

You can choose what level of strictness to apply to border checks.

Type Accepted Default
integer 0 or 1 or 2 1

Other Notes

Response

The above command returns JSON structured like this:


{
"status":"ok",
"balance":0,
"lat":39.56764454,
"lon":-105.00728197,
"accuracy":10,
"address":"High Line Canal Trail, Littleton, Douglas County, Colorado, 80129, United States of America"
}

The response will be a JSON object.

Parameter Description
status If the request is successful, ok is returned. Otherwise error is returned
message Any additional information from the server is returned here
balance This represents the remaining balance on the API token. Requests that return error are not charged and do not affect balance.
balance_slots This represents the remaining balance of device slots. Requests that return error are not charged and do not affect balance. If -1 is returned, then observe it as an error while calculating slots balance. This element will only exist if you are on a device plan.
lat The latitude representing the location
lon The longitude representing the location
accuracy The accuracy of the position is returned in meters
address The physical address of the location
address_details The physical address of the location broken into sub-components. Read more
aged Shown when the location is based on a single measurement or those older than 90 days or is an LAC fallback
fallback Shown when the location is based on a fallback. Possible options include ipf, lacf, scf.

Address Details

The API only returns components that have valid values for a location. Component town is normalized to city to make things simple. For more granular control, please use our Geocoding service - LocationIQ.

Components that would be returned are:

Errors

{
   "status": "error",
   "message": "error_message",
   "balance": 0
}

Possible return values for message when status is error by category

Authentication error

Parsing error

Unsuccessful

Geocoding

Forward Geocoding

Forward Geocoding is when you need to convert addresses (like a street address) into geographic coordinates (like latitude and longitude). You can then use these coordinates to do a number of things such as place markers on a map, calculate the distance between your office and those coordinates, send a drone over to that location, and so on.

Usage

<?php

$curl = curl_init('https://us1.unwiredlabs.com/v2/search.php?token=YOUR_API_TOKEN&q=SEARCH_STRING');

curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER    =>  true,
  CURLOPT_FOLLOWLOCATION    =>  true,
  CURLOPT_MAXREDIRS         =>  10,
  CURLOPT_TIMEOUT           =>  30,
  CURLOPT_CUSTOMREQUEST     =>  'GET',
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
import requests

url = "https://us1.unwiredlabs.com/v2/search.php"

data = {
    'token': 'YOUR_API_TOKEN',
    'q': 'SEARCH_STRING'
}

response = requests.get(url, params=data)

print(response.text)
curl --request GET \
  --url 'https://us1.unwiredlabs.com/v2/search.php?token=YOUR_API_TOKEN&q=SEARCH_STRING'
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://us1.unwiredlabs.com/v2/search.php?token=YOUR_API_TOKEN&q=SEARCH_STRING",
  "method": "GET"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

GET requests can be sent to the following URL:

https://us1.unwiredlabs.com/v2/search.php?token=YOUR_API_TOKEN&q=SEARCH_STRING

Replace us1 with an endpoint that’s closer to your location.

Query Parameters

Name Description Required
token Authentication Token Yes
q Address which we want to search for Yes
accept-language Preferred language order for showing search results. Read more. Optional
limit Integer value to limit the number of returned results Optional
countrycodes Limit search to a list of countries. Read more. Optional
viewbox The preferred area to find search results. (left, right, top, bottom) Optional

Response

The above command returns JSON structured like this:

{
  "status": "ok",
  "balance": 5000,
  "address": [{
    "lat": "40.6892474",
    "lon": "-74.0445404280149",
    "display_name": "Statue of Liberty, Hudson River Waterfront Walkway, Jersey City, Hudson County, New Jersey, 10004, United States of America",
    "road": "Hudson River Waterfront Walkway",
    "county" : "Hudson County",
    "city": "Jersey City",
    "state": "New Jersey",
    "country": "United States of America",
    "country_code": "US",
    "postal_code": 10004
  }, {
    "lat": "41.3438648",
    "lon": "-86.3111653",
    "display_name": "Statue of Liberty, Rue Guynemer, Odéon, 6e, Paris, Île-de-France, 75006, France",
    "road": "Rue Guynemer",
    "city": "Île-de-France",
    "state": "Paris",
    "country":"France",
    "country_code" : "FR",
    "postal_code": 75006
  }]
}
Name Description
status ok on success; error on error
balance Balance left in the account
address Array of Address objects found for the search query. Read more

Reverse Geocoding

Reverse geocoding is the process of converting geographic coordinates into a human-readable address.

Usage

<?php

$curl = curl_init('https://us1.unwiredlabs.com/v2/reverse.php?token=YOUR_API_TOKEN&lat=LATITUDE&lon=LONGITUDE');

curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER    =>  true,
  CURLOPT_FOLLOWLOCATION    =>  true,
  CURLOPT_MAXREDIRS         =>  10,
  CURLOPT_TIMEOUT           =>  30,
  CURLOPT_CUSTOMREQUEST     =>  'GET',
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://us1.unwiredlabs.com/v2/reverse.php"

data = {
    'token': 'YOUR_API_TOKEN',
    'lat': 'LATITUDE',
    'lon': 'LONGITUDE'
}

response = requests.get(url, params=data)

print(response.text)
curl --request GET \
  --url 'https://us1.unwiredlabs.com/v2/reverse.php?token=YOUR_API_TOKEN&lat=LATITUDE&lon=LONGITUDE'
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://us1.unwiredlabs.com/v2/reverse.php?token=YOUR_API_TOKEN&lat=LATITUDE&lon=LONGITUDE",
  "method": "GET"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

GET requests can be sent to the following URL:

https://us1.unwiredlabs.com/v2/reverse.php?token=YOUR_API_TOKEN&lat=LATITUDE&lon=LONGITUDE

Replace us1 with an endpoint that’s closer to your location.

Query Parameters

Name Description Required
token Authentication token Yes
lat Latitude of the location address Yes
lon Longitude of the location address Yes
zoom Zoom value lies between 0-18. Level of detail required where 0 is country and 18 is house/building Optional
accept-language Preferred language order for showing search results. Read more. Optional

Response

The above command returns JSON structured like this:

{
  "status": "ok",
  "balance": 5000,
  "address": {
    "display_name": "Southpark Lane, Littleton, Arapahoe County, Colorado, 80120, United States of America",
    "road": "Southpark Lane",
    "county": "Arapahoe County",
    "city": "Denver-Aurora-Lakewood",
    "state": "Colorado",
    "country": "United States of America",
    "country_code" : "US",
    "postal_code": 80120
  }
}
Name Description
status ok on success; error on error
balance Balance left in the account
address Address object found for the search query. Read more.

Notes

Address

Name Description
display_name Matched Address name for the given location
house_number House Number
road Road Name
neighbourhood Neighbourhood
suburb Suburb
city City name (normalized form of city, town, village, hamlet)
county County name (normalized form of county, state_district)
country Country name
country_code Country code
postcode Postal code

Accept Language

Preferred language order for showing search results, overrides the value specified in the Accept-Language HTTP header. Either uses standard rfc2616 accept-language string or a simple comma separated list of language codes.

Country Codes

Limit search results to a specific country (or a list of countries). Should be the ISO 3166-1 alpha-2 code. Here is a sample:

Country code Country
de Germany
gb United Kingdom
us United States of America

Errors

{
  "status": "error",
  "message": "Error message"
}

When certain types of errors are encountered, LocationIQ API responds the following error messages:

Error Message Description
NO_TOKEN The request does not contain the user’s token
INVALID_TOKEN The user’s token set is not valid
INACTIVE_TOKEN The user’s token is not active
INVALID_INPUT The request does not contain the required input in the specified format
DAILY_LIMIT The user has reached the daily limit allocated
NO_RESULTS The request is valid and we could not find a proper result
NO_MATCHES_FOUND We are unable to process your request
UNKNOWN_ERROR Due to an unknown error, we are unable to serve your request

Timezone

The Unwired Labs TimeZone API provides time offset data for locations on the surface of the earth.

Usage

GET requests can be sent to the following URL:

https://us1.unwiredlabs.com/v2/timezone.php?token=YOUR_API_TOKEN&lat=LATITUDE&lon=LONGITUDE

Replace us1 with an endpoint that’s closer to your location.

Query Parameters

<?php

$curl = curl_init('https://us1.unwiredlabs.com/v2/timezone.php?token=YOUR_API_TOKEN&lat=LATITUDE&lon=LONGITUDE');

curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER    =>  true,
  CURLOPT_FOLLOWLOCATION    =>  true,
  CURLOPT_MAXREDIRS         =>  10,
  CURLOPT_TIMEOUT           =>  30,
  CURLOPT_CUSTOMREQUEST     =>  'GET',
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
import requests

url = "https://us1.unwiredlabs.com/v2/timezone.php"

data = {
    'token': 'YOUR_API_TOKEN',
    'lat': 'LATITUDE',
    'lon': 'LONGITUDE'
}

response = requests.get(url, params=data)

print(response.text)
curl --request GET \
  --url 'https://us1.unwiredlabs.com/v2/timezone.php?token=YOUR_API_TOKEN&lat=LATITUDE&lon=LONGITUDE'
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://us1.unwiredlabs.com/v2/timezone.php?token=YOUR_API_TOKEN&lat=LATITUDE&lon=LONGITUDE",
  "method": "GET"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
Name Description Required
token Authentication token Yes
lat Latitude of the location Yes
lon Longitude of the location Yes

Response

The above command returns JSON structured like this:

{
  "status": "ok",
  "balance": 5000,
  "timezone": {
    "name": "Asia/Kolkata",
    "now_in_dst": 0,
    "offset_sec": 19800,
    "short_name": "IST"
  }
}
Name Description
status ok on success; error on error
balance Balance left in the account
timezone Timezone object found for the location. Read more

Timezone Response

Name Description
short_name Short name of the Timezone
offset_sec The offset from UTC (in seconds) for the given location. Considers DST savings.
now_in_dst Represents whether the zone currently observing DST or not
name Timezone name of the Location

Maps

Unwired Maps offers world-wide Street and Satellite maps. Our map tiles can be rendered by most open-source libraries. We recommend that you use Mapbox’s open-source GL javascript library for web projects and their iOS and Android SDKs for mobile projects to render our map tiles. Quick start with Mapbox >

If you need to support older browsers (IE 9 and older), you should Leaflet instead. Quick start with Leaflet >

Desktop Maps with Mapbox GL

We’ve added demos & code-samples for most popular use-cases here.

Desktop Maps with Leaflet

The raster maps below are rendered by the popular and open-source LeafletJS library. We’ve included a quick-start guide which will get you started on basics, including setting up a basic map, working with markers, polylines and popups, and dealing with events. For further reading, we recommend the comprehensive LeafletJS documentation.

Before writing any code for the map, you need to do the following preparation steps on your page:

Now you’re ready to initialize the map and do some stuff with it.

Setting up the map

Markers, circles and polygons

Working with popups

Dealing with events

Leaflet Further reading

For more advanced configurations and options, please refer to Leaflet’s documentation.

Mobile SDKs

For mobile platforms, there are again 2 libraries you can use:

Mapbox-gl Native SDK

For everything other than the most basic Android apps, you should use the Mapbox SDKs. We’ve created sample apps using these SDKs for both Android & iOS show-casing use-cases popular among our customers:

OSMDroid

Gradle dependency

  repositories {
      mavenCentral()
  }

  dependencies {
      compile 'org.osmdroid:osmdroid-android:5.6.5'
  }

Set a custom map tile source to Unwired Maps

  mMapView.setTileSource(new OnlineTileSourceBase("UnwiredMaps", 0, 18, 256, "",
      new String[] {
          "https://a-tiles.unwiredmaps.com/v2/obk/r/",
          "https://b-tiles.unwiredmaps.com/v2/obk/r/",
          "https://c-tiles.unwiredmaps.com/v2/obk/r/"
      }) {

            @Override
            public String getTileURLString(MapTile aTile) {
                return getBaseUrl() + aTile.getZoomLevel() + "/"
                            + aTile.getX() + "/" + aTile.getY() + ".png"
                            + "?auth=API_ACCESS_TOKEN";
            }
  });

In case you’d like to use OSMDroid, we’ve added sample code for you on the right:

For more info and documentation, please refer to osmdroid Wiki

Balance

The Balance API provides a count of request credits left in the user’s account for the day. Balance is reset at midnight UTC everyday (00:00 UTC).

Usage

GET requests can be sent to the following URL:

https://us1.unwiredlabs.com/v2/balance.php?token=YOUR_API_TOKEN

Replace us1 with an endpoint that’s closer to your location.

<?php

$curl = curl_init('https://us1.unwiredlabs.com/v2/balance.php?token=YOUR_API_TOKEN');

curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER    =>  true,
  CURLOPT_FOLLOWLOCATION    =>  true,
  CURLOPT_MAXREDIRS         =>  10,
  CURLOPT_TIMEOUT           =>  30,
  CURLOPT_CUSTOMREQUEST     =>  'GET',
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo 'cURL Error #:' . $err;
} else {
  echo $response;
}
import requests

url = "https://us1.unwiredlabs.com/v2/balance.php"

data = {
    'token': 'YOUR_API_TOKEN',
}

response = requests.get(url, params=data)

print(response.text)
curl --request GET \
  --url 'https://us1.unwiredlabs.com/v2/balance.php?token=YOUR_API_TOKEN'
var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://us1.unwiredlabs.com/v2/balance.php?token=YOUR_API_TOKEN",
  "method": "GET"
}

$.ajax(settings).done(function (response) {
  console.log(response);
});

Query Parameters

Name Description Required
token Authentication Token Yes

Response

The above command returns JSON structured like this:

{
  "status": "ok",
  "balance_geolocation": int,
  "balance_geocoding": int
}
Name Description
status ok on success; error on error
balance_geolocation Remaining balance left in the account for geolocation requests
balance_geocoding Remaining balance left in the account for geocoding requests

Errors

  {
    "status": "error",
    "message": "Error message"
  }

When certain types of errors are encountered, our API responds with the following error messages:

Error Message Description
INVALID_TOKEN The user’s token set is not valid
INACTIVE_TOKEN The user’s token is not active
UNKNOWN_ERROR Due to an unknown error, we are unable to serve your request
RATELIMITED_SECOND The user has exceeded the 1 request per-second limit for this endpoint

Changelog