Developers
The registry is published as static JSON files, rebuilt with the site. There is no key, no sign-up and no query string: every endpoint is a plain GET on GitHub Pages, and browsers can call it from any site (Access-Control-Allow-Origin: *).
Informational only, not legal advice or permission. Entries report what a public source says and are unverified by the owner unless marked owner_verified. An activity that is not listed is unspecified, never allowed. Local law and signs on site come first.
Endpoints (v1)
| GET | What |
|---|---|
/api/v1/index.json | Version, generated_at, counts, endpoint list, the tile scheme |
/api/v1/openapi.json | OpenAPI 3.1 description of every file and its schema |
/api/v1/places.json | Every entry as a compact record without geometry (467 now, about 565 KB) |
/api/v1/places/{id}.json | One full entry, with geometry and zones, e.g. rijksmuseum |
/api/v1/countries.json, /api/v1/countries/{cc}.json | Jurisdictions, and every entry in one (lower-case code, e.g. th, eu), including nationwide rules with no map point |
/api/v1/near/index.json, /api/v1/near/{lat}/{lng}.json | 1°×1° tiles for nearby lookups (8130 published tiles) |
/api/stats.json, /data/seed.json, /data/places.csv | Unversioned files from before v1; they keep working |
Near tiles
- A tile is keyed by
lat = floor(latitude)andlng = floor(longitude), and covers[lat, lat+1) × [lng, lng+1). For example, Bangkok (13.75, 100.49) is/near/13/100.jsonand Sydney (−33.87, 151.21) is/near/-34/151.json. - An entry is listed in the tile that holds its map point (
"match": "point") and in every tile its circle or polygon touches ("match": "area"). An area match means "may apply here": fetch the place file and test its geometry for an exact answer. - For the nearest places, read the tile and its 8 neighbours (lng wraps at ±180). Each tile lists the neighbours that exist. Empty tiles are not published and return 404.
near/index.jsonis a small list of every published tile key ("13/100", ...) plusurl_template,tile_size,countandgenerated_at, so an app can skip tiles that do not exist. - Entries with no point and no area (exam boards, nationwide rules) are in no tile; get them from
/countries/{cc}.json. - Chains and operators (
"applies_at": "own_sites") are in a tile'splacesonly where one of their listed sites lies ("match": "site", with the site'slat/lngand asiteobject). If they have no listed sites, their representative point puts them in the tile's separateoperatorslist. Show those as “Chains and operators with rules here” and never use them to decide what applies across an area. A tile can now have"count": 0when it holds only operators.
Chains, operators and the applies_at field (API 1.2.0)
Some entries cover many sites but carry one representative point: a theatre group, a members' club, a gym chain, a court or school system, exam rooms. Their rules apply only at their own sites, not across the city around that point. Every place record now has applies_at: "area" (a venue point, a mapped circle or polygon, or an area-wide law) or "own_sites", and sites: the sites an official page names, each {name, address, lat, lng, address_source} (coordinates are an OpenStreetMap geocode of that address). Most chains have no listed sites yet, so they never match a point. Right now 101 entries are own_sites and 6 of them list sites. GET /api/check and the MCP tool count them only within 1000 m of a listed site ("match": "site") and list the rest under chains_and_operators, which never decides the answer. All fields are additions: existing fields keep their meaning.
Status values
status is one of in_force, in_force_temporary, starts_soon (adopted, not yet in force) or proposed (new in API 1.2.0: the official record shows the rule under consideration, not adopted; 3 entries today). Only in-force entries decide a lookup. Treat any other value as not in force.
curl
# API index: version, build time, counts and the near-tile scheme curl -s https://openplacerules.org/api/v1/index.json # One place (full entry with geometry and zones) curl -s https://openplacerules.org/api/v1/places/rijksmuseum.json # Everything in one jurisdiction (lower-case code) curl -s https://openplacerules.org/api/v1/countries/th.json # The 1x1 degree tile around Amsterdam (lat 52.37, lng 4.89 -> 52/4) curl -s https://openplacerules.org/api/v1/near/52/4.json # CORS: GitHub Pages sends Access-Control-Allow-Origin: * curl -sI https://openplacerules.org/api/v1/places.json | grep -i -E '^(access-control-allow-origin|content-type):'
JavaScript (fetch)
Works in browsers and Node 18+.
// Nearest entries to a point, from the tile and its 8 neighbours.
const BASE = 'https://openplacerules.org/api/v1';
const wrap = (x) => ((x + 180) % 360 + 360) % 360 - 180;
function km(a, b, c, d) {
const r = Math.PI / 180, x = Math.sin((c - a) * r / 2) ** 2 + Math.cos(a * r) * Math.cos(c * r) * Math.sin((d - b) * r / 2) ** 2;
return 12742 * Math.asin(Math.sqrt(x));
}
async function nearest(lat, lng, n = 5) {
const y = Math.floor(lat), x = Math.floor(lng), urls = [];
for (const dy of [-1, 0, 1]) for (const dx of [-1, 0, 1]) {
if (y + dy < -90 || y + dy > 89) continue;
urls.push(`${BASE}/near/${y + dy}/${wrap(x + dx)}.json`);
}
// Empty tiles are not published, so a 404 just means "nothing there".
const tiles = await Promise.all(urls.map((u) => fetch(u).then((r) => (r.ok ? r.json() : null))));
const byId = new Map();
for (const t of tiles) if (t) for (const p of t.places) if (p.lat != null) byId.set(p.id, p);
return [...byId.values()]
.map((p) => ({ ...p, km: km(lat, lng, p.lat, p.lng) }))
.sort((a, b) => a.km - b.km)
.slice(0, n);
}
nearest(52.3600, 4.8852).then((list) => {
for (const p of list) console.log(p.km.toFixed(1) + ' km', p.name, JSON.stringify(p.rules));
});
Python
# Python 3, standard library only.
import json, math, urllib.error, urllib.request
BASE = "https://openplacerules.org/api/v1"
def get(url):
try:
with urllib.request.urlopen(url, timeout=20) as r:
return json.load(r)
except urllib.error.HTTPError as e:
if e.code == 404: # empty tiles are not published
return None
raise
def km(a, b, c, d):
r = math.pi / 180
x = math.sin((c - a) * r / 2) ** 2 + math.cos(a * r) * math.cos(c * r) * math.sin((d - b) * r / 2) ** 2
return 12742 * math.asin(math.sqrt(x))
def nearest(lat, lng, n=5):
y, x = math.floor(lat), math.floor(lng)
seen = {}
for dy in (-1, 0, 1):
for dx in (-1, 0, 1):
if not -90 <= y + dy <= 89:
continue
tile = get(f"{BASE}/near/{y + dy}/{(x + dx + 180) % 360 - 180}.json")
for p in (tile or {}).get("places", []):
if p["lat"] is not None:
seen[p["id"]] = p
return sorted(seen.values(), key=lambda p: km(lat, lng, p["lat"], p["lng"]))[:n]
index = get(f"{BASE}/index.json")
print(index["version"], index["generated_at"], index["stats"])
place = get(f"{BASE}/places/rijksmuseum.json")["place"]
print(place["name"], place["rules"], place["source"]["url"])
for p in nearest(13.7500, 100.4913): # Bangkok
print(round(km(13.75, 100.4913, p["lat"], p["lng"]), 1), "km", p["name"], p["rules"])
Sample apps and tools
- Place Rules for Android: an open-source Kotlin / Jetpack Compose reference app. It reads the near tile for your position plus its 8 neighbours, caches tiles for offline use, and has no tracking. MIT licence. Releases: github.com/openplacerules/android-sample/releases.
- validate-action: a GitHub Action that checks a
place-rules.jsonin your repository, like the validate page does in the browser. On GitHub Marketplace as “OpenPlaceRules Validate” (uses: openplacerules/validate-action@v1.1.0). Use v1.1.0: it accepts the optionalopenplacerulesverification property from /verify/;@v1still has the older schema.
Embeddable widget
Show one place's rules on any website with <script src="https://openplacerules.org/widget/v1.js" data-place="<id>"></script> (Shadow DOM, only calls this API), or an iframe at /embed/<id>/. Preview and snippets: /widget/.
Owner verification fields
Every place record has owner_verified (boolean), verification ("reported, unverified by owner" or "verified by owner (<method>, <YYYY-MM-DD>)") and owner_verification: null, or {status: "verified"|"lapsed", domain, method: "well-known"|"dns", verified_at, last_checked, lapsed_at, note, rules_from_owner}. A place verifies itself on /verify/: it publishes {"openplacerules": {"id", "token"}} in /.well-known/place-rules.json or a TXT record openplacerules-verify=<id>:<token> at _openplacerules.<domain>, and a daily GitHub Actions check confirms it (SPEC §7.3). A lapsed entry reads as reported again and carries a note.
Licence and attribution
- Data: ODbL-1.0. Credit “OpenPlaceRules” with a link to https://openplacerules.org, keep each entry's
source.url, and share derived databases under the same licence. Boundaries and geocodes: © OpenStreetMap contributors. Details in ATTRIBUTION.md. - Spec: CC-BY-4.0. Code: MIT. Every API file carries
licence,attributionandtermsfields. - Please cache: the data changes at most a few times a day. Use
generated_atto tell versions apart.
More
Validate a place-rules.json · Spec · JSON Schema · MCP server tools check_place_rules and search_place_rules · llms.txt · Badges