oslew docs
Console
Menu

Cell and Wi-Fi location

POST /v1/locate places a device from the radios around it: the cell towers it is in touch with and the Wi-Fi access points it can hear. It is for when there is no satellite fix — indoors, from a cold start, on a device without GNSS, or to save the battery a GNSS fix costs.

The answer depends entirely on the beacon data loaded for the area. The endpoint answers from survey feeds of where towers and access points are, loaded for the places they cover. Where no loaded feed knows your beacons, there is no answer.

So on the hosted API a scan of Mexican cell towers is answered, and a Wi-Fi-only scan, or one from another country, is not. No open dataset carries the positions of access points at usable coverage; Wi-Fi answers need a survey feed loaded for the area. Here is a real scan, four Telcel LTE towers as a phone near the Zócalo would see them:

curl
curl -X POST "https://api.oslew.com/v1/locate" \
  -H "Authorization: Bearer $GEO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cell":[{"id":"334-20-594-23103747","signal_dbm":-63},{"id":"334-20-595-24889601","signal_dbm":-72},{"id":"334-20-594-24890113","signal_dbm":-81},{"id":"334-20-594-23066114","signal_dbm":-90}]}'
Python
from oslew import Client

# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")

answer = client.locate(
    {
    "cell": [
        {"id": "334-20-594-23103747", "signal_dbm": -63},
        {"id": "334-20-595-24889601", "signal_dbm": -72},
        {"id": "334-20-594-24890113", "signal_dbm": -81},
        {"id": "334-20-594-23066114", "signal_dbm": -90},
    ],
},
)
TypeScript
import { Client } from "@oslew/client";

// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });

const answer = await client.locate({
  cell: [
    { id: "334-20-594-23103747", signal_dbm: -63 },
    { id: "334-20-595-24889601", signal_dbm: -72 },
    { id: "334-20-594-24890113", signal_dbm: -81 },
    { id: "334-20-594-23066114", signal_dbm: -90 },
  ],
});
Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 290
ratelimit-reset: 1

{
  "lat": 19.436397066914306,
  "lon": -99.1330676503093,
  "accuracy_m": 1205.6181643348004,
  "used": 4,
  "unknown": [],
  "admin": [
    {
      "doc": 2174,
      "id": "7f1f3634-1218-43e7-9538-ac3d1f43fc1c",
      "name": "México",
      "subtype": "country",
      "country": "MX",
      "region": null,
      "admin_level": null,
      "via": "interior",
      "provenance": {
        "name": "overture-divisions",
        "release": "2026-08-19.0",
        "license": "ODbL-1.0"
      }
    },
    {
      "doc": 61,
      "id": "0831989a-c65b-47db-802e-f930af64b9e4",
      "name": "México",
      "subtype": "country",
      "country": "MX",
      "region": null,
      "admin_level": null,
      "via": "interior",
      "provenance": {
        "name": "overture-divisions-maritime",
        "release": "2026-08-19.0",
        "license": "ODbL-1.0"
      }
    },
    {
      "doc": 1560,
      "id": "bc8dbc34-544b-47c4-bdb1-d3f5ecfc6af7",
      "name": "Ciudad de México",
      "subtype": "region",
      "country": "MX",
      "region": "MX-CMX",
      "admin_level": 1,
      "via": "boundary",
      "provenance": {
        "name": "overture-divisions",
        "release": "2026-08-19.0",
        "license": "ODbL-1.0"
      }
    },
    {
      "doc": 1380,
      "id": "b468c7e5-eb6f-44c8-bfeb-c60bce169f25",
      "name": "Cuauhtémoc",
      "subtype": "county",
      "country": "MX",
      "region": "MX-CMX",
      "admin_level": 2,
      "via": "boundary",
      "provenance": {
        "name": "overture-divisions",
        "release": "2026-08-19.0",
        "license": "ODbL-1.0"
      }
    },
    {
      "doc": 1522,
      "id": "2b1d49e2-98ef-4665-b9f6-1ce96c9f015b",
      "name": "Ciudad de México",
      "subtype": "locality",
      "country": "MX",
      "region": "MX-CMX",
      "admin_level": null,
      "via": "interior",
      "provenance": {
        "name": "overture-divisions",
        "release": "2026-08-19.0",
        "license": "ODbL-1.0"
      }
    },
    {
      "doc": 1423,
      "id": "96d18adf-e0bb-473c-affc-758969b272e1",
      "name": "Centro",
      "subtype": "neighborhood",
      "country": "MX",
      "region": "MX-CMX",
      "admin_level": null,
      "via": "boundary",
      "provenance": {
        "name": "overture-divisions",
        "release": "2026-08-19.0",
        "license": "ODbL-1.0"
      }
    },
    {
      "doc": 147,
      "id": "America/Mexico_City",
      "name": "America/Mexico_City",
      "subtype": "timezone",
      "country": null,
      "region": null,
      "admin_level": null,
      "via": "interior",
      "provenance": {
        "name": "timezone-boundary-builder",
        "release": "2026d",
        "license": "ODbL-1.0"
      }
    }
  ],
  "provenance": {
    "name": "mls",
    "release": "2024-03-27",
    "license": "Mozilla Location Service final export (2024-03-27), public domain"
  },
  "took_us": 111
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

The request

A JSON body, sent with Content-Type: application/json — without it the answer is a plain-text415 (see errors):

FieldIs
wifiAccess points: [{"id": BSSID, "signal_dbm": -48}, …]. The BSSID in any case, separated by colons, hyphens, dots or nothing — 02:00:00:00:00:00, 02-00-00-00-00-00 and 0200.0000.0000 are the same access point. Twelve hex digits.
cellTowers: [{"id": "mcc-mnc-lac-cid", "signal_dbm": -85}, …]. Four decimal numbers separated by hyphens.
signal_dbmOptional, on each: the received signal strength in dBm, as the device reports it.

Either list may be empty or absent, but together they must hold between 1 and 64 beacons. More than 64 is refused, not trimmed: trimming would answer a different question from the one you asked. A BSSID that is not twelve hex digits, or a cell id that is not four numbers, is not an error: it cannot match anything, and comes back inunknown.

A cell id is compared as written, apart from surrounding spaces. 334-020-594-23103747 and334-20-594-23103747 are different towers to the lookup, so send each part as a plain decimal number with no zero-padding, which is how the Mozilla survey spells them: country code 334, network20 (Telcel), then the area and the cell. For LTE and 5G, where platforms report a tracking area code and a 28-bit cell identity in place of GSM's LAC and CID, those two are the third and fourth parts, as in the example above.

How the fix is made

  1. Look each beacon up. Loaded feeds are searched in order and the first that knows a beacon wins. Beacons no feed knows are listed in unknown, exactly as you sent them.
  2. Prefer Wi-Fi. If two or more access points are known, towers are left out. An access point places a device to tens of metres; a tower to hundreds, and averaging one in would only pull the fix away.
  3. Weigh each beacon by its signal and by how precisely the feed knows it:signal ÷ max(radius, 10 m)², where radius is the feed's radius for that beacon andsignal is 10^((dBm + 100) / 20), held between 0.01 and 100. A beacon with nosignal_dbm counts as 1.
  4. Take the weighted centroid. With three or more beacons, any more than 1 km from it is dropped as moved — a router carried to a new flat, a phone's hotspot — and the centroid is taken again.
  5. Say how wrong it can be. accuracy_m is the larger of the beacons' weighted mean radius and twice their weighted spread around the fix, and never less than 5 m.

Two consequences of the weights are worth knowing when you build the request:

  • Strong signals saturate. The signal factor reaches its cap at −60 dBm, so an access point at −48 dBm and one at −55 dBm weigh the same. Below that, every 20 dB is a factor of ten.
  • Report signal for every beacon or for none. A beacon without signal_dbm weighs what one heard at −100 dBm would — a very faint signal. Mix the two and the beacons with a reported signal dominate the fix whether they deserve to or not.

Reading the answer

FieldIs
lat, lonThe fix.
accuracy_mThe radius, in metres, the true position is expected within. Draw it; do not drop a pin without it.
usedHow many beacons contributed to the fix.
unknownThe ids no feed knew, as given.
adminEvery administrative division containing the fix, outermost first — see administrative areas.
provenanceThe beacon feed that answered: name, release, licence.

The example sent four towers and the survey knew all of them, so unknown is empty andused is 4. The fix is in Centro, Cuauhtémoc, about 420 m from where the scan was taken, andaccuracy_m is 1,206 m: a tower's position in a crowd-sourced survey is where phones heard it, smeared over its coverage, so a cell-only fix is good to about a kilometre and says so. provenance is the survey's, mls, released 27 March 2024.

Treat few used as coarse. With one beacon the fix is simply where the feed puts that beacon, and accuracy_m is its radius; one tower means hundreds of metres or more. With two, it is a point between them. Only from three does the moved-beacon check run at all. accuracy_m already reflects this; used tells you why it is large.

When a vendor answers. An operator can configure a commercial positioning service as a fallback (GEO_LOCATE_UPSTREAM). If no loaded feed knows any of the beacons and one is configured, the beacons are sent to it, and its answer comes back with provenance naming the vendor, release api and licence vendor terms. On such an answer used is every beacon sent and unknown is empty, because the vendor does not say which it knew; itsaccuracy_m is the vendor's own figure, or 1,000 m where the vendor gives none. The terms on that position are the vendor's, not ours (see data and licensing). Thekeyless demo never calls a vendor: it answers from the loaded towers or not at all.

400 bodyMeans
give at least one wifi or cell beaconBoth lists were empty or missing.
at most 64 beaconsSend fewer; the strongest are the ones to keep.
none of the N beacons is knownNo loaded feed, and no vendor, knew any of them. Usually: no beacon data for this area, such as Wi-Fi only, or towers outside Mexico on the hosted API.
no beacon layer loadedThe deployment has no beacon feed and no vendor at all.

Two towers the survey never saw

Response
HTTP/1.1 400 Bad Request
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1

{
  "error": "none of the 2 beacons is known"
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

Collecting beacons

What a device will tell your code about the radios around it depends on the platform, and on the permission the user has given. In outline:

  • Android lets an app request a Wi-Fi scan and read each result's BSSID and signal level in dBm, and read the identity of the cells the device is using. Both need the user's location permission, and the system throttles how often an app may scan. The platform's own location service already does this kind of positioning;/v1/locate earns its place where you want the fix computed against your own beacon data, or on your server.
  • iOS gives ordinary apps no list of nearby access points and no tower identities — at most the network the device is joined to, behind an entitlement and location permission. On iOS, use Core Location.
  • A web browser cannot scan for Wi-Fi or read cell ids at all. There is no web API for it. The browser's own geolocation may use Wi-Fi internally, through the operating system or a location provider, but a page cannot see the beacons, so it cannot call this endpoint with them.
  • Trackers and embedded devices with a Wi-Fi or cellular radio and no GNSS are the natural case: the device scans, reports what it saw to your server, and your server asks for the fix. Keep the key on the server, as always (see authentication).

Send the beacons from one scan. Beacons gathered over several minutes by a device that moved describe two places at once, and the 1 km check only catches the gross cases.

Python
from oslew import Client, BadRequest

client = Client(base_url="https://api.oslew.com")

def fix_from_scan(cells: list[tuple[str, float]], wifi: list[tuple[str, float]] | None = None):
    """One scan's beacons as (id, dBm) pairs. Returns (lat, lon, accuracy_m, used) or None."""
    beacons = sorted([("cell", i, s) for i, s in cells] + [("wifi", i, s) for i, s in wifi or []],
                     key=lambda b: b[2], reverse=True)[:64]  # the strongest 64, if there are more
    body = {
        "wifi": [{"id": i, "signal_dbm": s} for kind, i, s in beacons if kind == "wifi"],
        "cell": [{"id": i, "signal_dbm": s} for kind, i, s in beacons if kind == "cell"],
    }
    try:
        fix = client.locate(body)
    except BadRequest:
        return None  # none of them known here: no beacon data for this area
    return fix["lat"], fix["lon"], fix["accuracy_m"], fix["used"]

Privacy

A BSSID identifies a place. A home router's BSSID, once anyone has mapped it, is as good as the home's address, and a list of the BSSIDs a phone saw through a day is a list of where its owner was. Treat beacon lists as location data about a person:

  • Send only what a fix needs: one scan's worth, when a position is actually wanted — not a continuous feed.
  • Do not keep beacon lists once you have the fix, and do not store them against a user id. The fix, with its accuracy_m, is what you needed.
  • Send no network names. The request has no field for an SSID; do not put one in an id.

On our side the query log records the fix's cell of about 2 km and the count of beacons used — never the beacon ids, and never the body (see what is logged). The exception to know about is the vendor fallback above: where a deployment configures one and no loaded feed knows your beacons, they are sent to that vendor, and the answer's provenance says when that happened.

Endpoints

POST/v1/locateplatform

A position from the Wi-Fi access points and cell towers a device sees, against a beacon feed: a weighted centroid, an accuracy radius, and the ids no feed knew.