Skip to main content
toiletnearest.com Search Open the map

The toilet data endpoint

Our live map reads toilets from one JSON endpoint, /api/toilets. You can call it too, with no key or sign-up, but it has no service guarantee and may change. For data in bulk, go to the sources instead.

Black wall signs pointing left to toilets for men and women and right to gender neutral toilets, beside a tiled entrance with a zigzag pattern
Toilet signs at the Suntec Singapore convention centre during Wikimania 2023. Photo: Fabebk, CC BY 4.0, cropped.

Before you use it

  • There are no API keys, accounts or access tiers, and no promise of uptime or of a stable format.
  • Each request that is not already cached asks OpenStreetMap’s public Overpass servers, which volunteers and companies run for free. Please keep requests few, and cache what you get.
  • For bulk data, take it from the source: the Toilet Map dataset (opens in a new tab) for the UK and OpenStreetMap (opens in a new tab) for everywhere else.

Request

GET https://toiletnearest.com/api/toilets

Query parameters
ParameterRequired?Meaning
latRequiredLatitude in decimal degrees.
lngRequiredLongitude in decimal degrees.
radiusOptionalSearch radius in metres, as a whole number. Default 2000; anything above 50000 is treated as 50000.
quickOptionalquick=1 skips OpenStreetMap and the published datasets and returns only our UK copy and, in New Zealand, the New Zealand records from the lists kept in our code. It answers faster.
curl "https://toiletnearest.com/api/toilets?lat=51.5072&lng=-0.1276&radius=1000"

Response

A JSON object. Its shape, with values left out:

{
  "elements": [
    {
      "type": "node",
      "id": …,
      "lat": …,
      "lon": …,
      "tags": { "amenity": "toilets", "fee": "no", "wheelchair": "yes", … }
    },
    …
  ],
  "_cached": false,
  "_osm_count": …,
  "_local_count": …,
  "_published_count": …,
  "_seed_count": …
}
Response fields
FieldMeaning
elementsThe toilets, in OpenStreetMap’s JSON element format: type, id, lat, lon and tags. Ways and relations are placed at their centre.
elements[].tagsOpenStreetMap tags as recorded, such as name, fee, wheelchair, opening_hours and changing_table. Records from other sources are converted to the same tag names. A missing tag means not recorded.
elements[]._localtrue for a record from our copy of the Great British Public Toilet Map (UK).
elements[]._publishedtrue for a record from a council or government dataset. tags._source, tags._source_terms and tags._source_layer give the publisher, its terms and the layer.
elements[]._seedtrue for a record from one of the two lists kept in our code. Some of their details were filled in without a source we can cite; treat them as unverified.
_osm_count, _local_count, _published_count, _seed_countHow many elements came from each source.
_cachedtrue when the answer came from our five-minute cache.
_quicktrue on a quick=1 answer, which carries only _local_count and _seed_count.

Only OpenStreetMap records carry OpenStreetMap ids. The ids of records from other sources are numbers we make up, and can match an unrelated OpenStreetMap id, so use the flags above to tell them apart.

Where the records come from

  • OpenStreetMap, live, through two public Overpass servers: objects tagged amenity=toilets (or the misspelling amenity=toilet), up to 2,000 per request.
  • Our copy of the Toilet Map, in the UK. A record within 15 metres of an OpenStreetMap toilet is left out as a likely duplicate.
  • Council and government datasets, queried live when the point is inside their coverage: Wellington City Council, Australian Government (National Public Toilet Map via NSW Spatial Portal), City of New York — NYC Parks / NYC Open Data, North Ayrshire Council, City of York Council, City of Austin (ArcGIS Hub) and Région de Bruxelles-Capitale / Brussels Hoofdstedelijk Gewest.
  • Two lists kept in our code, added where OpenStreetMap returns few toilets, and always in New Zealand. These are the _seed records.

The methodology explains each source and its gaps.

Errors, empty answers and caching

  • Without lat or lng, the reply is HTTP 400 with {"error":"Missing lat/lng","elements":[]}.
  • If no Overpass server answers within six seconds, the OpenStreetMap part is simply empty and no error is returned. An empty or short list does not prove there are no toilets.
  • Answers are cached on our server for five minutes for each small area, so requests for nearby points can get the same answer, and are sent with Cache-Control: public, max-age=300.

Licences and credit

Every record keeps the licence of its source. If you show the data, credit each source you use:

Other paths under /api serve our own pages and are not supported for outside use. The old /api/v1/toilets path has been retired and now answers 410 Gone. See also the terms.