Announcement: v1 of our API that only supports nearest-cell based location has been deprecated. v2 is now available publicly.

API v1 Documentation

Usage

Requests are sent using GET to the following url:
http://unwiredlabs.com/process.php

Request body:

Send the following data as a GET request
  • token - Your API token. If you don't have one, get one free here!
  • mcc - Mobile Country Code of your operator's network
  • mnc - Mobile Network Code of your operator's network
  • cid - On GSM, it's the Cell ID (CID). On CDMA, it's the Base Station ID (BID). On WCDMA, it's the UTRAN/GERAN Cell Identity (UC-Id). Our API fully supports the 16-bit Cell ID value for WCDMA networks while only partially supporting the 32-bit Cell ID value.
  • lac - Location Area Code of your operator's network (GSM/WCDMA). On CDMA, it's the Network ID (NID)
All fields are compulsory.
http://unwiredlabs.com/process.php?token=your_token&mcc=404&mnc=49&cid=1161&lac=31

Response body

Here's a successful output in JSON format:

{
    "status": "ok",
    "balance": "0",
    "lat": 27.42531,
    "lon": 82.17283,
    "cid": "1161",
    "lac": "31",
    "mnc": "49",
    "mcc": "404",
}
                

When you get this, it's time to refill your balance with us!:

{
    "status": "error",
    "message": "Invalid token/No balance",
    "balance": "0",
}
                

Test it out

Fields with * are required.

Get a free token here.

Example script (PHP)

<?php
/*
* Sample script to test Unwired Labs API v1 - DEPRECATED
*
* Created: 20th July, 2013
* Author: Unwired Labs
*
*/
//URL of our API
$url = "http://us1.unwiredlabs.com/process.php"; //defined in includes.php
//Parameters to pass. Replace with your token and your cell tower data
$qry_str = "?token=your_token&mcc=310&mnc=410&lac=7033&cid=17811";
//Initialize cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . $qry_str);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, '3');
$response = trim(curl_exec($ch));
if (curl_errno($ch)) {
exit(curl_error($ch));
}
curl_close($ch);
$response = substr($response, strpos($response, "{"));
$data = json_decode($response, true); //converts response into array
//If there wasn't a "status" array key, something's wrong with the response
if (!isset($data['status']))
exit("Uh oh, it didn't work well. Is the API url correct?");
//If it returned an error message, exit & print the error
if ($data['status'] != "ok")
exit("Whoops, there was an error: '{$data['message']}'");
//Everything's fine so far, so print the latitude & longitude.
echo "Lat: " . strval($data['lat']) . " Lon: " . strval($data['lon']);
?>