APIs
Wi-Fi and cell tower geolocation API
A Wi-Fi and cell tower geolocation API estimates where a device is from the radios around it, without a satellite fix. oslew’s POST /v1/locate takes the access points and towers from one scan and returns a weighted position, an accuracy radius and the ids it did not recognise. It can only answer where a beacon feed covering the area is loaded, and beacon ids leave the deployment for a commercial vendor only if that deployment has configured one.
Last reviewed
Satellite positioning fails indoors, drains batteries and takes time from a cold start. The radios a device can already hear are an alternative: a home router or an office access point stays where it was installed, and a device that hears several of them is near all of them. /v1/locate turns that observation into a coordinate, provided someone has surveyed where those radios are.
What goes in
The request is a JSON body with Content-Type: application/json:
wifi: access points, each anid— the BSSID, in any common spelling — and an optionalsignal_dbm.cell: towers, each anidof four hyphen-separated numbers — mobile country code, network code, area code and cell identity — with an optionalsignal_dbm.
Together the two lists must hold at least one beacon and at most 64 beacons. More than that is refused rather than trimmed, because trimming would silently answer a different question; keep the strongest. An id that cannot be a beacon — the wrong number of hex digits, a cell id with three parts — is not an error, just a beacon nothing can match, and it comes back listed as unknown. Cell ids are compared as written, so send network codes with the zero-padding the device reports.
How the fix is worked out
- Look up each beacon in the loaded feeds, in order; the first feed that knows a beacon supplies its position and radius.
- Prefer Wi-Fi. When two or more access points are known, towers are left out, because a tower’s coverage is far wider and averaging it in only drags the fix away.
- Weight each beacon by its reported signal and by how tightly the feed places it, so a strong, precisely surveyed access point counts most.
- Take the weighted centroid, and with three or more beacons, drop any that sit implausibly far from it as moved — a router carried to a new flat, a phone’s hotspot — then recompute.
- State the uncertainty as
accuracy_m, the larger of the beacons’ weighted radius and their spread around the fix.
Two consequences shape the request. Signal strength saturates: past a strong level, two access points weigh the same however loud one is. And a beacon sent without signal_dbm is treated as very faint, so report signal for every beacon or for none; mixing the two lets the ones with a figure dominate.
Reading a coarse answer
The answer gives lat, lon, accuracy_m, used, unknown, the administrative chain at the fix and the provenance of the feed that answered. used explains the radius. With one beacon, the fix is simply where the feed places that beacon, and the radius is its coverage — for a lone tower, a wide area. With two, the fix is a point between them. The moved-beacon check only runs from three. Draw the circle rather than a pin; a dot without its radius claims a precision the data does not have.
The chain is the same one the boundaries API returns, so a fix arrives with its country and region codes. If accuracy_m is wide and a division is flagged as decided near its edge, the device may well be in the neighbouring area.
Where the beacon positions come from
This endpoint answers entirely from beacon data loaded for the area — a survey feed, commercial or crowd-sourced, with provenance naming it. No open dataset carries access-point positions at usable density, so there is no fallback to open data, and where no feed covers your devices there is no answer.
A deployment can add one more source. POST /v1/locate sends a device’s beacon ids to Unwired Labs or Combain only when GEO_LOCATE_UPSTREAM and GEO_LOCATE_KEY are set and no loaded feed knows any of them; with them unset, nothing is sent. The request to the vendor waits at most 3 seconds. A vendor’s answer names the vendor in provenance, reports every beacon as used and none as unknown because the vendor does not say which it knew, and carries vendor terms in place of an open licence. A deployment that must make no outbound calls leaves the fallback unset; the air-gapped deployment page lists it among the settings to check.
Which devices can collect beacons
What a device will tell your code depends on the platform and on the permission the user has granted:
| Platform | Wi-Fi access points | Cell towers |
|---|---|---|
| Android app | Scans return BSSIDs and signal levels, with location permission; the system throttles scan frequency | The cells the device is using, with location permission |
| iOS app | No list of nearby access points; at most the joined network, behind an entitlement | Not available to ordinary apps |
| Web page | No web API exists for scanning | No web API exists |
| Tracker or embedded device | Whatever its radio firmware reports | Whatever its modem reports |
Send the beacons from one scan. A list gathered over minutes by a device that moved describes two places, and the outlier check catches only gross cases. On Android the platform already offers its own network location; this endpoint earns its place when the fix should come from your own beacon data, or be computed on your server.
Privacy
A BSSID identifies a place: once mapped, a home router is as revealing as the home’s address, and a day of scans is a record of where a person went. Send a scan only when a position is needed, keep the fix and its radius rather than the beacon list, and never put a network name in an id — the request has no field for one.
On the service side, Request bodies are not logged: not the Wi-Fi and cell ids a device saw, not a map-matching trace, not a batch file’s rows. Positions are kept only as the level-12 cell they fall in, about 2 km across. The security page sets out the full log schema, and what a geocoding request reveals applies the same reasoning to address queries.
What it costs
/v1/locate is in the Platform product: $699 a month for 20 requests a second sustained, burst 100, no monthly quota. One scan is one request whatever its size. Retrying a scan that no feed recognises will not change the answer, so do not loop on those refusals.
Limits worth knowing
- No beacon feed for the area means no answer; the endpoint cannot position from open data.
- Beacons from a moving device, or from several scans, blur the fix.
- A fix from a single tower is coarse by nature, and
accuracy_mwill say so. - Collection is impossible in browsers and restricted on iOS, which confines practical use to Android apps, trackers and servers relaying their reports.
- Vendor answers carry the vendor’s terms, not an open licence.
Bottom line
Use /v1/locate where devices can report the radios they hear and a beacon feed covers the places they go: trackers, Android fleets, indoor assets. Send one scan with signal for every beacon, draw the accuracy circle, and treat a small used as a coarse answer. Leave the vendor fallback off unless you have decided that beacon ids may leave your deployment.
Questions
Can I call the geolocation API from a web page?
No, for two reasons. Browsers expose no way to scan for Wi-Fi access points or read cell ids, so a page has nothing to send. And the key belongs on a server: the service sends no CORS headers and reads the key only from the Authorization header. The natural caller is your backend, relaying what a device or tracker reported.
Does it work on iPhone?
Not with beacons collected by an ordinary app. iOS gives apps no list of nearby access points and no cell tower identities, so there is nothing to put in the request; use Core Location on iOS. Android apps can scan with the user’s location permission, and embedded trackers with a Wi-Fi or cellular radio are the most natural fit.
How accurate is a Wi-Fi position?
Each answer states its own accuracy_m, the radius the true position is expected within, and that is the number to use. It depends on how many beacons matched and how precisely the feed knows them. Several access points usually give a tight fix; a single cell tower gives a coarse one, and the answer’s used count explains a large radius.
Are my beacon ids sent to a third party?
Only if the deployment has configured a vendor fallback and no loaded feed recognises any of the beacons. With the fallback unset, which is the default, nothing leaves the service. When a vendor does answer, the provenance names it and the licence reads vendor terms, so you can tell from the answer.
What happens where no beacon data is loaded?
There is no answer rather than a guess. If no feed and no vendor knows any beacon, the request is refused with a 400 saying none of them is known; a deployment with no beacon source at all says no beacon layer is loaded. Positioning from open data alone is not possible, because no open dataset maps access points at usable density.