Overpass API query examples
99 ready-to-run queries, each explained line by line and run live on our full-planet server. Copy one and change the place or the tags.
Getting started
The building blocks: bounding boxes, areas, radius searches and output modes.
Your first query: cafés in a bounding box
The simplest useful Overpass query: every café inside a rectangle of latitudes and longitudes, with a line-by-line explanation.
Search inside a city by name
Use area["name"=…] to search inside the real boundary of a city instead of a rectangle. Example: every bakery in Vienna.
Everything within a radius of a point
Find features within a distance of a coordinate with the around filter. Example: pharmacies within 1 km of Times Square.
Nodes, ways and relations at once (nwr)
Search nodes, ways and relations in one statement with nwr, and get one point per result with out center. Example: every car park in Bern.
One bounding box for the whole query
Set a bounding box once in the settings line instead of repeating it in every statement. Example: benches and waste baskets in the old town of Bern.
Several tags at once (union)
Combine several searches with a union to find features tagged in different ways. Example: all drinking water sources in Zürich.
Food & drink
Cafés, restaurants, pubs, bakeries and drinking water.
Drinking water fountains in a city
Find every public drinking water fountain in a city. Example: the 2,000+ nasoni of Rome.
All cafés in a city
List every café in a city, as points or buildings. Example: Lisbon.
Vegan and vegetarian places
Find restaurants, cafés and shops with vegan options using the diet:vegan tag. Example: Berlin.
Restaurants by cuisine
Filter restaurants by the cuisine tag. Example: every pizzeria in Naples.
Pubs in a city
Find all pubs in a city, with names and opening hours. Example: Dublin.
Breweries in a country
Search a whole country by ISO code. Example: every brewery in Belgium.
Supermarkets open on Sunday
Search inside opening hours with a regular expression. Example: supermarkets in Zürich that open on Sundays.
Shops & services
Shops, brands, pharmacies, banks, schools and other everyday places.
Migros supermarkets in Switzerland
List every store of a retail chain with the brand tag. Example: all Migros supermarkets in Switzerland.
All locations of a chain by Wikidata ID
Find every outlet of an international chain with brand:wikidata. Example: McDonald’s restaurants in Switzerland.
Pharmacies in a city
Find every pharmacy in a city, including dispensing information. Example: Madrid.
ATMs and banks
Find cash machines and bank branches with one regular expression. Example: Singapore.
Hospitals in a country
List every hospital in a country, mapped as points, buildings or campuses. Example: Ireland.
Schools in a city
Find all schools in a city, with their grounds. Example: Amsterdam.
Post boxes in a city
Find every post box, with collection times. Example: Edinburgh.
Wheelchair-accessible public toilets
Combine two tags to find accessible facilities. Example: wheelchair-accessible toilets in Barcelona.
Glass recycling points
Find recycling containers by the materials they accept. Example: bottle banks in Geneva.
Embassies and consulates
Find diplomatic missions with the office=diplomatic tag. Example: embassies in Bern.
Places with free Wi-Fi
Find cafés, libraries and other places that offer free internet access. Example: Barcelona.
Transport
Stations, stops, lines, roads, parking and charging.
Bus stops in a city
Find every bus stop in a city. Example: Helsinki.
Train stations in a country
List every railway station in a country. Example: Switzerland.
Metro lines of a city
Get the routes of a metro network with their geometry and colours. Example: the Paris Métro.
Tram network
Draw the tram network of a city from its route relations. Example: Zürich.
One bus line by its number
Find a single bus or trolleybus line by its ref and get its route. Example: line 31 in Zürich.
EV charging stations
Find electric vehicle chargers with their sockets and operator. Example: Oslo.
Car parks with their capacity
Find car parks and read the number of spaces. Example: Munich.
International airports worldwide
A worldwide query without area: every airport tagged as international, with IATA and ICAO codes.
Motorway network of a country
Get every motorway segment of a country with its geometry. Example: Switzerland.
Speed cameras
Find fixed speed cameras in a country. Example: the Netherlands.
Ferry routes
Draw the ferry routes of a country. Example: the Greek islands.
Cycling & walking
Cycleways, bike sharing, hiking routes and footpaths.
Cycleways and bike lanes
Map the cycling infrastructure of a city: separate cycleways plus lanes and tracks along roads. Example: Copenhagen.
Bike sharing stations
Find bike rental and sharing docks. Example: the Vélib’ stations of Paris.
Hiking routes in a region
Get marked hiking trails as route relations with their geometry. Example: around Zermatt.
Steps and stairs in a city
Find every flight of steps in a city, useful for accessibility and routing. Example: hilly Lisbon.
Ski lifts and cable cars
Draw every aerial lift of a ski area. Example: Zermatt.
Playgrounds
Find every playground in a large city. Example: Greater London.
Nature & outdoors
Peaks, lakes, rivers, parks, trees, beaches and protected areas.
Peaks higher than 4000 m
Compare numbers with an if: filter. Example: every Alpine summit above 4000 metres.
Named lakes of a country
Get lake outlines, including multipolygons, with their names. Example: Switzerland.
Rivers of a country
Draw the river network of a country from its waterway lines. Example: Slovenia.
Parks in a city
Get park outlines with their names. Example: Manhattan.
Trees by genus or species
Query the street trees of a city by genus. Example: the lime trees (Tilia) of Vienna.
Viewpoints
Find scenic viewpoints in a region. Example: around Lake Lucerne.
Campsites in a country
Find campsites with their facilities. Example: Norway.
Beaches
Find every beach on an island. Example: Mallorca.
National parks and nature reserves
Find protected areas by protection class. Example: Switzerland.
Glaciers
Draw glacier outlines in a mountain range. Example: the Bernese Alps.
Mountain huts
Find staffed and unstaffed mountain huts. Example: Switzerland.
Elevation & profiles
Heights of peaks, huts, passes and stations, the vertical rise of lifts, route profiles and sea depths.
Peaks with their height from elevation data
Add a height to every summit with elevation=1 and compare it with the ele tag of OpenStreetMap. Example: the peaks around Zermatt.
Mountain huts and their altitude
Every mountain hut in a region with its altitude, highest first, from elevation=1. Example: the canton of Valais.
Ski lifts and cable cars: vertical rise
The bottom and top height of every lift, from out geom with elevation=1. Example: the lifts of Zermatt, sorted by vertical rise.
Road passes and their height
Find the mountain passes on the main roads of a country and add their height. Example: the road passes of Switzerland, highest first.
The highest train stations
List the railway stations of a country by altitude with elevation=1, and see why stations in tunnels read too high. Example: Switzerland.
Lakes and their surface elevation
The water level of every named lake in a country from elevation=1. Example: Switzerland, from the highest mountain lakes down.
Elevation profile of a mountain railway
Draw the climb of a railway line from its route geometry and the elevation profile API. Example: the Pilatus railway, the steepest rack railway.
Elevation profile of a hiking route
Distance, ascent and descent of a hiking route from OpenStreetMap, with its elevation profile. Example: the Matterhorn Trail in Zermatt.
Offshore wind turbines and the water depth
The sea depth at every turbine of offshore wind farms, from the GEBCO grid via elevation=1. Example: the German Bight.
Buildings & places
Buildings, addresses, land use, landmarks and boundaries.
Building outlines
Get every building footprint in a small area. Example: the old town of Bern.
Tall buildings by number of floors
Find buildings with 15 or more floors using a numeric if: filter. Example: Frankfurt.
Vineyards
Draw land use areas such as vineyards. Example: the Lavaux terraces on Lake Geneva.
All addresses on a street
List every house number on a street. Example: Bahnhofstrasse, Zürich.
Places of worship
Find churches, mosques, synagogues and temples, with religion and denomination. Example: Kraków.
Castles in a region
Find castles, palaces and fortresses. Example: Rhineland-Palatinate.
Museums in a city
Find museums and galleries. Example: Berlin.
The boundary of a country
Get the outline of a country as a polygon. Example: Liechtenstein.
Municipalities of a region
Get all municipal boundaries inside a region. Example: the canton of Zug.
Cities and towns of a country
List places by size with the place tag, including population. Example: Italy.
Which areas contain a point
Reverse lookup with is_in: list the country, region and municipality of a coordinate.
Infrastructure
Power, telecoms and emergency infrastructure.
High-voltage power lines
Draw the power transmission grid of a region. Example: the Swiss Plateau.
Wind turbines
Find every wind turbine in a country. Example: Denmark.
Power plants by source
List power plants with their energy source and output. Example: Spain.
Telecom masts and towers
Find communication towers and masts. Example: the Netherlands.
Defibrillators (AEDs)
Find public defibrillators. Example: Switzerland, where volunteers mapped over 17,000.
Fire hydrants
Find fire hydrants with their type and diameter. Example: Lausanne.
Data quality
Find missing tags, fixme notes and outdated features to improve the map.
Features without a name
Find features that miss a tag, here restaurants without a name, to improve the map. Example: Prague.
Shops without opening hours
Find shops that are missing opening hours, a common mapping task. Example: Ljubljana.
Fixme notes
Find everything mappers flagged for review with a fixme tag. Example: Luxembourg.
Disused and closed features
Find features marked as disused with lifecycle prefixes. Example: Bern.
Peaks without an ele tag
Find summits that do not have a height in OpenStreetMap, with a reference height from the elevation model. Example: the Valais and Mont Blanc.
History & changes
The map at a past date, changes between two dates, version histories, deleted objects and last edits. On the Pro and Business plans.
The map at a past date
Query OpenStreetMap as it was on a past day with the date setting. Example: the cafés of central Zürich on 1 January 2015.
Changes in an area between two dates (adiff)
An augmented diff lists what was added, changed or deleted between two dates, with the old and the new version. Example: Paradeplatz, Zürich, late 2024.
New and closed restaurants (diff)
Compare two dates and keep only what was added or removed, with diff and compare. Example: restaurants in the Niederdorf, Zürich, in 2023 and 2024.
Deleted objects in an area
Find what was deleted in an area between two dates, with its last version and who deleted it. Example: Paradeplatz, Zürich, April to June 2024.
Every version of an object (timeline)
List the versions of an element with timeline, then fetch each one with retro: tags, position, time and user. Example: the Matterhorn summit.
Features not edited for years (out meta)
With out meta, every result gets the version, time and user of its last edit. Example: shops in Bern that nobody has edited since 2020.
Advanced techniques
CSV export, counting, statistics, polygons, intersections and set operations.
Export results as CSV
Get a spreadsheet instead of JSON with [out:csv]: choose the columns, header and separator. Example: hotels in Geneva.
Count features without downloading them
Use out count to get only the number of matching elements. Example: how many trees Vienna has mapped.
Count values of a tag
Group and count with a for loop and make: how many restaurants of each cuisine. Example: Zürich.
Total length of cycleways
Compute a sum over geometries with make and length(). Example: kilometres of cycleways in Bern.
Cafés near train stations
Search around the results of another search: every café within 150 m of a station. Example: Zürich.
Search inside your own polygon
Use the poly filter to search inside any shape you draw. Example: restaurants in a part of Midtown Manhattan.
Where two streets cross
Find the intersection node of two named streets with set intersection. Example: Langstrasse and Badenerstrasse, Zürich.
Ways with their nodes (recurse down)
The classic (._;>;); out; pattern: get ways together with the nodes that give them coordinates. Example: Langstrasse, Zürich.
Shops inside a mall
Turn a mapped building into an area with map_to_area and search inside it. Example: Sihlcity, Zürich.
Regular expressions on tag values
Match several values, parts of values and any case with ~ and ,i. Example: sushi and ramen places in Hamburg.
No example matches. Try another word, or ask us for a query.
Guides
Errors and limits
Errors and limits of the public Overpass servers, their causes and fixes, and the alternatives.
overpass-api.de: “429 Too Many Requests”
Why the public server rejects your queries, how its slots work, and how to stay within its limits.
overpass-api.de: “406 Not Acceptable”
Why the public server refuses scripts with a default user agent, and how to set your own in Python, R, curl and JavaScript.
Banned from overpass-api.de
Connection refused after too many 429s: what gets an address banned, how long it lasts, and retries within the rules.
Overpass API errors explained
429, 504, “runtime error: Query timed out”, “out of memory”, empty results: causes and fixes, with retry code.
Overpass API alternatives
Public instances, self-hosting and six hosted services compared, with prices and history data, and when you need which.
Overpass speed: overpass-rust and Overpass API compared
Response times for overpass-rust and Overpass API 0.7.62 on the same hardware, and what makes the Rust engine faster.
Tools and libraries
Point your tools at another Overpass server, step by step.
Overpass Turbo: use another Overpass server
Where the server setting is, the URL format, and what to check when Turbo shows an error.
QuickOSM (QGIS): change the Overpass server
Add a server in the QuickOSM settings, or in custom_config.json on older versions, and use it in Processing.
OSMnx: custom Overpass server and node elevations
Set overpass_url, avoid a 60-second pause before every query, and add node elevations without a Google key.
osmdata (R): use another Overpass server
set_overpass_url() in the R package osmdata, with the key kept out of your scripts.
Overpass API in Claude, ChatGPT and Cursor (MCP)
Connect an AI assistant to the Overpass API, geocoding and elevation with one URL, and what it can then answer.
Overpass API in Python
requests, overpy and overpass: query any Overpass server from Python, with retries and GeoJSON.
History and changes
The map at a past date, what changed in an area between two dates, every version of one object, and the error that diffs give with JSON output.
Overpass history queries: [date:], [diff:] and [adiff:]
Query OpenStreetMap as it was on a past date, or the changes between two dates, back to September 2012.
OpenStreetMap changes in an area between two dates
Which restaurants opened, closed or changed in a part of Zurich from 2023 to 2025, with one adiff query and a short Python script.
Version history of an OpenStreetMap object
Every version of a node, way or relation since 2012, with date, user and changed tags, from timeline and retro.
Overpass: “does not support the diff or adiff mode”
Why [diff:] and [adiff:] fail with [out:json] or CSV, and two ways to get the changes anyway.
Elevation
Heights and depths for points, routes and GPX tracks, and how the elevation APIs compare.
A Google Elevation API alternative
The same request and response format as Google, prices compared, and results you may store and show on any map.
Alternatives to Open-Elevation and Open Topo Data
What the free public elevation APIs allow, what self-hosting takes, and how to switch.
Add elevation to a GPX file
Distance, ascent and descent of a track with one curl command, and a Python script that writes the heights into the file.
Elevation for your website
Code for a tour profile, the summits seen from your hotel, the sun side of a property and places above the snow line, one page for each.
An elevation profile for your tour pages
A map of the route with its profile below: distance, metres up and down, highest point and walking time. The heights are looked up once per tour.
Draw the summits seen from your hotel
The skyline seen from a terrace, a restaurant or a mountain station, with the name and height of each summit, as a picture for your website or for print.
Height, slope and sun side for property listings
For each flat or house: the metres above sea level, the slope and the side the ground faces, from five lookups when you save the listing.
Which of your places get snow
Heights for your chalets, stops or customers in one request, compared with the snow line of the forecast, and a map that turns white above it.
Maps for your website
Code to copy for your shop on a map, a store locator, a delivery area and property listings, filled with your own places.
Add a map with your location to your website
A marker with your address, opening hours and a directions link, for the contact page, in one block of HTML and without a Google account.
A store locator map for your website
All your shops from a spreadsheet: a list beside the map, “near me” sorted by distance, and markers that group when you zoom out.
Show your delivery area on a map
Zones around your shop with their delivery fee, or an area you draw, and a check for any place a customer clicks.
Property listings on a map
Price labels on the map, a popup with a link for each flat or house, and filters for rent, buy and rooms.
Map libraries
Our vector map tiles in MapLibre, OpenLayers, Leaflet, React and QGIS, and moving from Mapbox GL JS to MapLibre.
MapLibre GL JS tutorial: your first map
A map with a style URL, markers and popups, your GeoJSON as a layer, other styles and languages, and controls. With script tags or Vite.
Vector map tiles in OpenLayers
A vector map with a MapLibre style in OpenLayers: ol-mapbox-style with script tags or Vite, markers and GeoJSON on top, and MapLibre as a layer for every style.
Vector map tiles in Leaflet
Vector maps in Leaflet through maplibre-gl-leaflet: script tags or a bundler, markers and GeoJSON on top, other styles, and protomaps-leaflet without WebGL.
MapLibre vs Leaflet vs OpenLayers
How each draws, vector tiles, 3D, projections, formats and download size, the same map in all three, and when to use which.
react-map-gl with MapLibre
A map component with react-map-gl 8 and MapLibre 6: style, markers, popups, 3D terrain, the key in an environment variable, Next.js.
Vector tiles and terrain in QGIS
Add a vector tile layer with a style URL, which styles QGIS can draw, terrain heights as a raster, and contour lines.
From Mapbox GL JS to MapLibre GL JS
The code changes, what does not have a counterpart, plugins, styles and tiles, and the setWorkerUrl call that MapLibre 6 needs with a bundler.
Map tiles
Errors of map tile services and map libraries, and what map tiles cost.
Map tile API errors explained
401, 403, 429, “Access blocked” on OpenStreetMap tiles, blank and grey maps: causes and fixes for MapLibre, Leaflet and Google Maps.
Fixing “Access blocked” on OpenStreetMap tiles
Why tile.openstreetmap.org blocks tiles, which settings remove the Referer (Helmet, Django, nginx), and the fix for Leaflet, OpenLayers and MapLibre.
MapLibre “Unable to parse the tile”: causes and fixes
Gzip tiles without Content-Encoding, double compression and HTML pages: how to tell them apart, with nginx, Apache, Caddy and S3 fixes.
Fixing “This page can't load Google Maps correctly”
What RefererNotAllowedMapError, ApiNotActivatedMapError and BillingNotEnabledMapError mean, the fix for each, and what a map costs without Google.
Map tile API prices compared
Mapbox, MapTiler, Stadia Maps, OpenFreeMap and VersaTiles at 100,000, 2 million and 10 million tiles a month, with the sources.
Maps step by step
3D terrain, hillshading, contour lines, trails and sea depths in MapLibre.
3D terrain in MapLibre GL JS
Terrain from one style parameter or in code, exaggeration, sky and camera, heights under the mouse, and what 3D costs in tiles.
Hillshading in MapLibre GL JS
A hillshade layer under the roads, its colours for light and dark maps, and the five shading methods of MapLibre.
Contour lines in MapLibre GL JS
Contour lines as vector tiles: line and label layers, major and minor lines, labels in feet, and computing them in the browser instead.
A hiking map in MapLibre GL JS
Trails coloured by SAC grade, a popup with the trail name, huts and stops, 3D terrain, and your own route on top.
A nautical map with depths and sea marks
The sea coloured by depth, depth contours, buoys and lights in their colours, in one style or added to your own.
Geocoding
Errors and limits of Nominatim, Google and other geocoding services, and what to do about them.
Geocoding API errors explained
“Access blocked”, 403, 429 and 509 on Nominatim, OVER_QUERY_LIMIT and REQUEST_DENIED on Google, geopy errors and empty results.
Nominatim: “Access blocked”, 403 and 429
Why nominatim.openstreetmap.org blocks scripts and apps, what its usage policy allows, and requests it accepts.
geopy: GeocoderInsufficientPrivileges and other errors
What each geopy exception means, the user_agent check of the Nominatim geocoder, and the settings for RateLimiter.
Google Geocoding: REQUEST_DENIED and OVER_QUERY_LIMIT
Every status of the Google Geocoding API with its cause and fix, the error_message texts, and what geocoding costs without Google.
Run these with your own key
Every example runs unchanged on overpass.ch, on the full planet with minutely updates. The free plan runs all of them except the history examples, which need Pro or Business.
Map data © OpenStreetMap contributors, available under the Open Database Licence.