Talk:Overpass API

From OpenStreetMap Wiki
Jump to navigation Jump to search

Please note server outages or malfunctions on Overpass API/status.

Feedback channel

Is it a feedback channel somewhere ?

Yes. You can write me an eMail at roland(dot)olbricht(at)gmx(dot)de. If you find a malfunction or server outage, please note it on Overpass API/status. If you are subscribed to the mailing list <emph>osm-dev</emph>, you could also write an email there. As this is a spare time project, I won't warrant any reaction time, up to 3 days may happen. --Roland 06:48, 25 October 2011 (UTC)

github pull request and bug tracking

That page starts to be big and we don't really know what are the known bugs and what are those solved. Have you thought about using a bug tracker ? Do you prefere that some developers join you before using more complex bug tracking ? (If that is just a matter of setting that up, I can provide you with an allready installed one if you wish). sletuffe 22:51, 20 December 2012 (UTC)
One day, I'll be searching before asking, in any case here is the bug tracker : [1] if someone search it sletuffe 22:56, 20 December 2012 (UTC)


query error

I've got errors on queries on http://78.46.81.38/api/sketch-route?159059 and other relation ids.

Firefox says :

Erreur d'analyse XML : entité non définie
Emplacement : http://78.46.81.38/api/sketch-route?159059
Numéro de ligne 8, Colonne 20 :<title>Line 2 from &rel_from; to &rel_to;</title>

--FrViPofm 09:22, 20 February 2010 (UTC)

Yes, you can write me an eMail at roland(dot)olbricht(at)gmx(dot)de or just write here. Thank you for pointing me to the error, this should now be corrected. Unfortunatly, this means that these relations show proper error messages: they are bus lines, but they don't have any stops as members. Thus, the generator can't generate a list of stops from them. You could use for example JOSM with the Public Transport Plugin to easily add stops. --Roland 13:00, 21 February 2010 (UTC)

Licensing

I would be useful to know what kind of usage is acceptable for this API. Can it be used for open source software, how about for commercial software? User:alecdhuse 16:09, 16 February 2012 (UTC)

Do you mean the software or the API service itself ? If the fist, the source code is here on gitorious : http://gitorious.org/osm3s, and although there is no GPL's licence text with the sources, it is licenced as GPL v2 (the author mentionned a bug that prevent from including the GPL text, which I must admit, is rather weird ;-) ) sletuffe 17:28, 16 February 2012 (UTC)
For the software: I'm the author. I'm simply not a lawyer and I have no idea what (license text, links, remarks) to put where (source code, head files only, license file somewhere) to properly express the license. I've seen projects that have put a one-line comment at the top of every file. But I think, the license text must be included somewhere. The rumor of a bug comes from the statement: If had hoped GNU automake would somehow help with placing a license remark (explanation in the manual, auto-adding something somewhere, sample files somewhere). -- Roland 2012-02-16 19h44 UTC
Well I'm not an expert as well, but this might be a little scary that in your source tree there is not a word about the licence (Will that guy try to sue me if I use his software ?). Following : [2] it says you should include a file at the root of your sources with this text http://www.gnu.org/licenses/gpl-2.0.txt and add to every files a line of copyright and a line saying this software is released under GPL v2. sletuffe 22:25, 16 February 2012 (UTC)
For the API. As there is no resource shortage, I have no formal policy yet. The background are the following considerations:
  • All users should have a fair chance of using the service.
  • I don't give any warranty that the server is available or keeps a certain minimum level of performance.
The technical limits are:
  • for all servers: The serializer doesn't process more than roughly 5 queries per second and responds with an error message instead. I could increase the capacity here, but then high load would result in slow queries. I deem the first solution better.
  • for overpass-api.de: There is a total bandwith soft quota of Hetzner at 5 TB per month. Currently, the server uses 0.06 TB. Thus there is much capacity reserve.
  • for overpass.osm-rambler.ru: The server and hosting are kindly donated by Rambler for the OSM community. The figures are similar.
This results in the following usage recommandations:
  • The API may be used for any kind of client and in any organizational model. I don't make restrictions here.
  • Be prepared that more than 5 requests per second may result frequently in error messages.
  • I strongly suggest not to use the API for more than 50 GB per day per service.
  • I don't give any warranty that the server is available or keeps a certain minimum level of performance.
  • Please write me a mail (roland(dot)olbricht(at)gmx(dot)de) if you want be informed about downtimes, need response times guarantees or plan to use the API with more load for more than 30 days.
-- Roland 2012-02-16 20h20 UTC


Thanks for the information. For some background: I am currently writing some software to make custom maps and export them as image, tiles, and other map formats. I'm looking for a good way to include data from OSM and was wondering if the API would work, until I could get my own OSM mirror up. I'm thinking of including this in early versions of the software until I can afford to create my own service to provide OSM data. User:alecdhuse 16:017, 17 February 2012 (UTC)

Public transport

Public_transport

I put here the url of the very handfull tool to check bus lines. --FrViPofm 23:45, 26 February 2010 (UTC)

Link unfortunately no longer works. Mmd (talk) 18:05, 29 June 2014 (UTC)

Something wrong ?

Erreur d'analyse XML : aucun élément trouvé
Emplacement : http://78.46.81.38/api/sketch-line?network=Ginko&ref=32&correspondences=20
Numéro de ligne 1, Colonne 1 :

for line 421941 b a u j s but routes are right :

--FrViPofm 00:17, 4 March 2010 (UTC)

URL is obsolete in the meantime, thus closing this one. Mmd (talk) 16:02, 9 September 2014 (UTC)

Trolleybus routes

Trolleybus lines (route=trolleybus) are not rendered - attempting to sketch them results in "No relation found".

To reproduce: 92 relation 913880 relation 913907 Stanton 00:17, 15 May 2010 (UTC)

Issue can no longer be reproduced with the example provided, hence closing this issue. Mmd (talk) 16:03, 9 September 2014 (UTC)

Stops tagged as amenity=bus_station

Apparently, if one of the stop members of the relation is tagged as area=yes amenity=bus_station, it is omitted completely. For example: 80 relation 611446 relation 611538

The first stop (Bonola) is tagged as area=yes amenity=bus_station described above and missing from the sketch. This seems incorrect to me as, to my knowledge, bus_station is the tag to be used for a larger bus terminal where multiple lines stop at dedicated platforms, and representing it with an area is encouraged. Stanton 00:21, 15 May 2010 (UTC)

I've now found a potential workaround: on the way that passes the bus_station, create a node where the bus actually stops and tag it as public_transport=stop_position, name=* and add it to the line relation as Role stop. Do not add the bus_station itself to the relation. This seems to be a clean way of mapping to me, as it represents the actual situation (it even adds some detail by specifying where exactly a particular line stops). Results look OK, the above example now displays correctly. Stanton 18:59, 8 November 2010 (UTC)

Stops messed up in sketch

In some cases incorrect stop names are displayed - names are mixed up or the same stop name is displayed multiple times.

Mild example: 19 relation 661028 relation 661000

Here just one stop name is wrong: the 11th (from Roserio) is displayed as "Duomo" when in fact it should be "Piazzale Accursio". (Duomo is the last stop.) One-way stops (which are present in only one direction) seem to be particular prone to this error, though I have seen it also on two-way stops. Then again, some routes work fine and I can't make out a difference between those that work and those that don't.

A more extreme one would be: 78 relation 420649 relation 445904

This one is botched beyond recognition and usability: names are either missing completely, or the same name is repeated over and over multiple times.

And finally: 69 relation 536964 relation 537040 relation 536992 relation 537008 Stanton 00:29, 15 May 2010 (UTC)

You can try omitting the style "padua" which has been personalized for Padova (I inserted some abbreviations and so on which are good to show a better sketch in the case of Padova - multiple stops along the same street) --Tizianos 22:55, 15 June 2010 (UTC)
The examples I gave now work, maybe something's been updated in the meantime. Anyway, I'm not sure if the Padova style really was the culprit as it should just be stop names and some extra information, but swapping stop names...? I'll keep an eye on it and see if the error's really gone. Stanton 23:33, 15 September 2010 (BST)

Train Station not on the tracks is missing in the output

There is a train station near Milan (Parabiago: Link on OSM ) which, while it is part of the S5 rail route relation 1016814, it's not displayed in the output of http://78.46.81.38/api/sketch-line?network=SITAM&ref=S5&style=padua (it should be located between Vanzago and Legnano).

Might it be due to the fact that the station is not represented as a node on the rail line, but as a separate building placed near the track?

--Stco 16:46, 28 July 2010 (UTC)

What is tagged as station - the building (area) or a single node? If the building is tagged, then it might be the same issue I reported for bus stations above (which would indicate that stops which are not single nodes are ignored). Stanton 23:36, 15 September 2010 (BST)

Problems with RER D

Hello,

I'm a French contibutor from OSM and this script have many problem with the RER D, a local train line. The official line map is here but the script give this. The problems are :

  • The lisibility is not the best
  • The north branch of the line is losed, but exists : click
  • Two stations : Goussainville and Juvisy isn't in the map, but they have the role stop and are the only stations in closed way, not in a singule node

Can you please resole this errors ?

Sorry for my english, Thank's, --JonathanMM 16:24, 19 February 2011 (UTC)

I'm sorry for the late answer. I often miss the comments here on discussion pages of the wiki. Please contact me also per eMail roland(dot)olbricht(at)gmx(dot)de.
The tool has not been designed to render such really complex lines; my current algorithm is too stupid for such lines. A more sophisticated algorithm will take some time
(expect four to eight weeks) to deleop and implement. In the meanwhile I can offer you only a comparable tool at
http://78.46.81.38/api/draw-line?network=RER&ref=D&font-size=12.0&scale=25.0.
By the way, if you have ideas or suggestions how to render complex lines, you are highly welcome to present them here and send them to me.
-- Roland.olbricht 19:43, 03 March 2011 (UTC)

Problems with opening hours surpassing midnight

Hi,

I've got some problems in rendering correctly the opening hours that run across midnight.

I don't know if I'm doing it wrong, if it's a bug or a missing feature.

My opening_hours tag is equal to "Mo-Th 05:15-24:00; Fr-Sa 05:15-24:00, 00:00-01:00; Su 05:15-24:00".

Ideally, I'd like to see something like "sunday-thursday 05:15-00:00, friday-saturday 05:15-01:00".

I'm very far from it because the result is "monday-wednesday 05:15-24:00, thursday 05:15-24:00, friday 00:00-01:00, 05:15-24:00, saturday 00:00-01:00, 05:15-24:00, sunday 05:15-24:00".

Any idea how to fix it ?

Thanks, --Don-vip 01:54, 31 March 2011 (BST)

Problems with stop order

Hi,

When I add stops to a bus line, they are displayed in the diagram in the order I create them and not their order belong the line (see the problem and the real map).

How can I fix this (without retagging all stops one by one in the right order) ?

Thanks, --Kalon33 11:57, 14 June 2011 (BST)

Editing style files for line diagrams

Hi, I tried in the section "Using style files" to edit padua or wuppertal style files but the "Edit style" text input in the next page is empty: I would like to not erase what already exists in these files. Is it possible to display the existing content? Thanks. Damouns 09:27, 9 August 2011 (BST)

This should be fixed now. -- Roland 23:08, 17 August 2011 (UTC)

Single direction stops with the same name of the terminus

There are issue with the rendering of single direction stops that have the same name of the terminus. These stops are rendered like double direction stops. http://www.overpass-api.de/api/sketch-line?ref=8&network=ATAC&style=italy

The first "Casaletto" is the terminus, and the second is a single direction stop for "Casaletto" terminus, but rendered like a double direction stop. Is there a solution of that issue? --Madeco 17:10, 15 March 2012 (UTC)

More line selection features in the PT Line Diagram Generator

There is a problem when more than one line of he same ID exists in the same network. For example: The Network VBB(Verkehrverbund-Berlin-Brandenburg) have three Tram-Linies with the ID 2.

Verkehrsverbund_Berlin-Brandenburg#Straßenbahnen

But only one appears [3]

A Solution might be if a third parameter(operator) exists, like: (CV = Cottbusverkehr)

http://www.overpass-api.de/api/sketch-line?network=VBB&ref=2&operator=cv&style=wuppertal

I've added the third parameter, so it should now be possible to deal with the same line number multiple times in the same network.
Is the third parameter "operator" like [4]?

Also a nice feature would be if you could use the color of the line if set in the route-relation.

This is already implemented. Could vou give an example where this doesn't work?
Ok, thanks. :) I found the problem. I put the color tag in the route-master relation, like [5]. When I put the tag in every line relation everything works fine. Maybe it is possible to look at the router-master relation, too.

Proposed_features/Public_Transport#Route

Thanks and great work!

Double Rendering Problems

Hi, I've some problems on rendering, using the new schema (placing "stop" (node public_transport=stop_position on the way) immediately followed by "platform" (node public_transport=platform near)) for every stop. It uses both nodes and creates a mess in the image: example --Arlas 22:07, 4 May 2014 (UTC)

Please check this pull request on github https://github.com/drolbr/Overpass-API/pull/126 Mmd (talk) 15:53, 9 September 2014 (UTC)




XAPI compatibility layer

Relations in XAPI compatibility layer

It seems that the XAPI compatibility layer doesn't handle relations in the way the XAPI page describes. Specifically this: "For each matching relation the nodes and ways referenced by that relation are also returned.". It seems Overpass simply returns the relation but not any members. Though from the wording it sounds like it shouldn't include the member-nodes of ways, which seems strange. Rasher 21:09, 4 October 2011 (BST)

Are pipes broken?

http://www.overpass-api.de/api/xapi?*[@meta][highway=motorway|motorway_link][ref=*][bbox=-77.7502441,36.5272948,-74.9926758,38.4965935] gives no results, even though using simply motorway or motorway_link returns many. --NE2 09:59, 23 December 2011 (UTC)

The result is wrong, but for a different reason. The pipe is treated as ordinary character when more than one key=value attribute is present. I'll fix that with the next version. -- Roland 28 Dec 2011


Missing attribute 'version'

When I try to open http://www.overpass-api.de/api/xapi?*[@meta][ref=I 90 Business] in JOSM it tells me that node 1564593971 has no 'version' attribute. --NE2 03:42, 28 December 2011 (UTC)

Same error message here, none of the "Meta data" samples on the Wiki page seem to work at the moment. --mmd 28 December 2011

See status page. I've screwed up the meta data while doing the version update. I'm sorry for that. I'll plug out the phone next time when I type on the command line :) A planet reimport is in progress but will take until Friday morning -- Roland 28 Dec 2011

Relation query is incomplete

http://overpass.osm.rambler.ru/cgi/xapi?relation[@meta][bbox=-87.6928711,23.9561363,-79.6728516,31.0811655] (all of Florida) doesn't include any of the state road relations (e.g. relation 380105). --NE2 15:15, 23 January 2012 (UTC)

This was a well known bug in the stable software version running on the Rambler instance. I've updated that software version now, so the bug should be gone now. -- Roland 2012 Jan 29, 09h20 UTC

Escaping in XAPI compatibility layer

Escaping in predicates does not seem to work like in XAPI, for example

http://overpass-api.de/api/xapi_meta?*[maxspeed%3A%5C%5BMo-Fr%3B700-1700%5C%5D%3D%2A]

returns a parse error - see Xapi#Escaping for details. This breaks taginfo. -- Eckhart 00:27, 9 June 2012 (BST)

Parse error can no longer be reproduced, however the query returns an empty result. Mmd (talk) 16:07, 9 September 2014 (UTC)

<bounds> element

As far as I can tell, the Overpass API does not return <bounds> elements in the XML - at least when used with XAPI Compatibility Layer. This is different from other XAPI services, and also differs from .osm files from other sources (OSM API, JOSM). The missing <bounds> caused me a bit of a debugging headache; I "solved" the problem for now by switching to open.mapquest's XAPI service. My queries look like this:

http://www.overpass-api.de/api/xapi?map?bbox=15.728027,52.130791,15.780762,52.163151[@meta]

--Tordanik 02:05, 22 April 2012 (BST)

Just use Overpass API QL instead of XAPI Compatibility layer, it includes the bounds. Mmd (talk) 16:01, 9 September 2014 (UTC)
I can't find the <bounds> element in any Overpass API responses. Can you give an example of a query that returns it? Skarkkai (talk) 15:29, 17 May 2016 (UTC)
You need to provide a global bbox in your Overpass QL query, see this issue for details: https://github.com/drolbr/Overpass-API/issues/251 Mmd (talk) 16:46, 17 May 2016 (UTC)

recurse in bbox query [solved]

The main page states : the map query, to collect all data from a given bounding box:

<union>
  <bbox-query s="51.249" n="51.251" w="7.148" e="7.152"/>
  <recurse type="node-relation" into="rels"/>
  <recurse type="node-way"/>
  <recurse type="way-relation"/>
</union>
<print mode="meta"/>

However, by doing such call I receive incomplete ways (those which have at least one node outside the bbox) So I have added <recurse type="way-node"/> wich helped. But I'm unable to organise my recurse statements to also get relations for wich the way is a member. Is there an order in the recurse statement ? I've read http://www.overpass-api.de/#section.recurse but I might not understand correctly what the "name of a set" is and if that can help me in my quest sletuffe 01:49, 19 December 2011 (UTC)

All this reminds me the mod_rewrite apache page : "OverpassAPI's recurse statements are dammed cool voodoo, but still voodoo", here is how, I manage to get what I wanted, but have no ideas why it works and if that's optimal :

<union>
  <bbox-query s="51.249" n="51.251" w="7.148" e="7.152"/>
  <recurse type="node-relation" into="rels"/>
  <recurse type="node-way"/>
  <recurse type="way-relation"/>
  </union>
  <union>
  <item/>
  <recurse type="way-node"/>
</union>
  <union>
  <item/>
  <recurse type="way-relation"/>
</union>

And this page [6] is a damn cool source of information for overpass api where what you want is not where you expect it to be, but still is in somewhere ! sletuffe 01:31, 22 December 2011 (UTC)

Output Formats

Alternative Output Format?

Hello! Is there an alternative format for data output (e.g. .pbf or .o5m)? --Marqqs 21:11, 21 December 2011 (UTC)

Some ideas are mentioned in this Github ticket. Mmd (talk) 17:55, 29 June 2014 (UTC)

Overpass QL

not-operator?

Is there a not operator? Basstoelpel 21:07, 18 January 2012 (UTC)

Not yet. There are two not operators that may make sense: Negating specific values out of a key, e.g. all elements with key 'oneway' without those with value 'no'. This will come with the next version. The other one would be to negate any clause in a query statement. That's much more difficult and therefore not on the to do list at the moment. -- Roland
How about elements without a key, such as [highway=motorway][NOT[lanes=*]]? --NE2 23:44, 20 January 2012 (UTC)
[highway=motorway][lanes!~"."] should do. Mmd (talk) 17:57, 29 June 2014 (UTC)


Partial Matches on Keys

I'm trying to match on a partial tag to get any nodes/ways with an address in NZ. This gives me anything with a postcode or a street but it seems inefficient:

 <union>
   <query type="node">
     <bbox-query s="-59.0" n="-25.5" w="157.5" e="179.9"/>
     <has-kv k="addr:postcode" />
   </query>
   <query type="node">
     <bbox-query s="-59.0" n="-25.5" w="157.5" e="179.9"/>
     <has-kv k="addr:street" />
   </query>
 </union>
 <print/>


You can search for partial value attributes but can you search for partial key matches? I would like to be able to do something like <has-kv k="addr:*" />

The search for a partial key isn't implemented. If it were implemented with the current database structure, it would be painfully slow. I will do it on the To-Do-List, be it might take some months to extend the database structure.
On the other hand, the above code is not as inefficient as it looks. It may help to write a script like
  echo "<union>"
  for i in addr:postcode addr:street; do
  {
    echo "<query type="node"><bbox-query s="-59.0" n="-25.5" w="157.5" e="179.9"/><has-kv k="$i"/></query>"
  }; done
  echo "</union><print/>"
to generate such a query for multiple addr:* instances. -- Roland 2012-03-12 07h55 UTC


(Partial) key machtes based on regular expressions is available now, see Github Issue 59 for details. Mmd (talk) 15:29, 9 September 2014 (UTC)

Relation members and roles

I can't seem to find a way in any of the language references to only get relation members that have a specific role. Is this possible at the moment? Thanks! --Joshdoe 10:15, 15 March 2012 (UTC)

+1, see also: http://lists.openstreetmap.org/pipermail/talk-de/2013-January/100717.html --Tyr 13:16, 20 January 2013 (UTC)
Restriction to relation member with a specific role is described on the Overpass QL page. Mmd (talk) 18:03, 29 June 2014 (UTC)


Documentation of parameter <area-query ref="XXXXXX"/>

at https://help.openstreetmap.org/questions/15748/extract-statistics-for-a-city I came across the parameter area-query that seems to enable an area defined by a boundary relation to take tha data from, instead of a bounding box.

Where is this (new?) parameter described in detail? or am I blind?

And how does a query look like if I know a place defined by a certain boundary relation (for example with admin_level=8) and I want to get all highways that have the key name= with any value? Thus I want to get a list of all named streets belonging to a place or city with boundaries. --Stephan75 20:49, 5 September 2012 (BST)

Looks like roland is in the process of migrating documentation from a good old flat html file to the osm wiki (I couldn't find this on http://overpass-api.de/ any more) but here you can find a slightly outdated copy : http://api.openstreetmap.fr/ )
With the area-query explained here : http://api.openstreetmap.fr/#section.area_query sletuffe 10:50, 6 September 2012 (BST)


Simple recursion is not returning

The following query runs fine and returns all the nodes less than 50m away from the "Paris" node:

<osm-script>
  <query type="node">
    <has-kv k="place" v="city"/>
    <has-kv k="name" v="Paris"/>
  </query>
  <query type="node">
    <around radius="50"/>
  </query>
  <print/>
</osm-script>

Now I want to find the ways that use these nodes, so I add naively a recurse statement:

<osm-script>
  <query type="node">
    <has-kv k="place" v="city"/>
    <has-kv k="name" v="Paris"/>
  </query>
  <query type="node">
    <around radius="50"/>
  </query>
  <recurse type="way-node"/>
  <print/>
</osm-script>

Unfortunately, that doesn't return (or it's way too slow). What I am doing wrong ? Ocroquette 09:12, 6 December 2012 (UTC)

It must be "node-way" instead of "way-node", because you are going from nodes to ways:
<osm-script>
  <query type="node">
    <has-kv k="place" v="city"/>
    <has-kv k="name" v="Paris"/>
  </query>
  <query type="node">
    <around radius="50"/>
  </query>
  <recurse type="node-way"/>
  <print/>
</osm-script>
--Roland

Of course you are right. It was a copy-paste error. However, your query doesn't return anything: Query on overpass-api.de Ocroquette 10:09, 6 December 2012 (UTC)

The query returns ways only. This makes sense for example if you want to get the streetnames. If you want to display the result, you also need the nodes referred by the ways:
<osm-script>
  <query type="node">
    <has-kv k="place" v="city"/>
    <has-kv k="name" v="Paris"/>
  </query>
  <query type="node">
    <around radius="50"/>
  </query>
  <union>
    <recurse type="node-way"/>
    <recurse type="way-node"/>
  </union>
  <print/>
</osm-script>
--Roland

Thanks, that makes sense. Part of the confusion was due to inconsistencies on the documentation page. Please review my changes.

I have also created a dedicated FAQ. Ocroquette 12:23, 6 December 2012 (UTC)

Overpass Server

Query address for rambler

What is query addres for rambler server? I'm trying to use address from description, but I get error 404... Pbm 14:28, 1 January 2012 (UTC)

Please have a look at http://overpass.osm.rambler.ru/query_form.html. There you can enter a query. Alternatively, you can use http://overpass.osm.rambler.ru/cgi/interpreter resp. http://overpass.osm.rambler.ru/cgi/xapi to directly send queries to. Roland 2012 Jan 3, 20:00 UTC

Server HW

This page lists the main server's hardware as "4 cores, 64 GB RAM" but on its munin stats I rather see something like "8 cores, 32 GB RAM". What's correct? just being curious ;) -- Tyr (talk) 15:38, 14 August 2013 (UTC)

Thank you for the hint, I've corrected the values. I myself also needed to lookup and left the result here. --Roland

Contributed Scripts

Query script

Here is a bash script that takes an overpass query written in a .txt file (the first argument) and runs it, writing the results to a filename of your choosing (the second argument).

  • Query.txt
data=

[timeout:600];


(
	node["name"="Bonn"];
	node (around:1000) ["name"="Gielgen"];
);

out meta;
  • overpass_query
#!/bin/bash


	if [[ $# -ne 2 ]]
	then
	echo -en "\n\n\tUsage:  $0 queryFile.txt outputFile.osm\n\n"
	exit
	fi

queryFile="$1"
outputFile="$2"

echo -en "\n\nrunning query and writing to '$outputFile':\n\n"
cat "$queryFile"

time wget --timeout=0 -O "$outputFile" --post-file="$queryFile" "http://overpass-api.de/api/interpreter"
  • To run the script save the two files above into Query.txt and overpass_query respectively and then execute the following command (note you will probably need to give the script execute permission with "chmod +x overpass_query" first).
./overpass_query Query.txt query.osm

Miscellaneous

Query last 20 changsets in a bbox

Osm.org hat the "changes" tab. The "normal" api is slow on that. I would like to query the last 20 changesets of an area, exclude Robots, retrieve all affected nodes, way and relations with one fast query. Is that possible?

How to combine query and area-query for ways

For example how to get all {Key|highway|platform} ways from city Prague (relation 439841) ... well I have found out myself

  <area-query ref="3600439841" />
  <recurse type="node-way" />
  <query type="way">
    <item />
    <has-kv k="highway" v="platform"/>
  </query>
  <print />

cool.


Proper escaping in meta export (print.cc)

In XML, & needs to be escaped as &amp;. Currently, standard conform parsers throw an error, e.g. osm2shp from the Osmium framework, …

terminate called after throwing an instance of 'std::runtime_error'
  what():  XML parsing error at line 308:145: not well-formed (invalid token)
Aborted

… when parsing the following file (only line 308) …

  <node id="683970" lat="48.2531004" lon="16.4216139" version="12" timestamp="2011-07-17T22:10:02Z" changeset="8753170" uid="26818" user="David & Christine Schmitt"/>

-- Simon04 21:34, 8 September 2011 (BST)

Wishlist

Note: Consider creating a Github issue instead: https://github.com/drolbr/Overpass-API/issues

nearest n objects that satisfy predicate to point

One thing that I think the Overpass API could add which would be very useful: the ability to specify some criteria and get back all the objects that match some predicate based on distance to a point. The closest I can find to this at the moment is using Cloudmade's API per the directions here. It'd be great if that kind of thing was supported by Overpass. Tom Morris 21:56, 14 January 2013 (UTC)

Does the around statement fit your needs? An example, another example and the reference. -- Roland
No it doesn't. (I'd like this feature too.) The problem with "Around" is that is requires a limiting radius, whereas we'd like a limiting number N. Imagine trying to find the nearest 3 bus-stops to (a) a point in central London, (b) a point in the middle of the sea. The radius required in each case would be massively different. --Danstowell (talk) 12:46, 2 February 2013 (UTC)

Case-insensitive regex matching

It would be nice if regexes could also be case-insensitive. Most regex libraries allow this, so I'll assume that the one employed by the Overpass API also does. If so, the only question is how to incorporate the feature in the query syntax. I would suggest regvi=// (i for insensitive) to accompany regv=// in XML; maybe an operator ~~ (negated as !~~) in Overpass QL? -- Oli-Wan (talk) 09:19, 7 May 2013 (UTC)

It is already implemented. An example:
node[name~"holtorf",i];out;
and
<has-kv case="ignore" k="name" regv="holtorf"/>
-- Roland
Whoops, sorry. Guess I should make an appointment at the ophthalmologist's :( -- Oli-Wan (talk) 10:18, 7 May 2013 (UTC)

'newer' for way/relation

Hi,

I'd like to monitor changes in my region with overpass (turbo). I can see nodes that are changed since a timestamp, but with ways and relations, it doesn't seem to work.

 <bbox-query {{geocodeBbox:Hildesheim}} />
 <query type="way">
   <item/>
   <newer than="2014-02-22T00:00:00Z"/>
 </query>
 <print mode="meta"/>

gives a zero result --Trublu (talk) 12:40, 25 February 2015 (UTC)

Try to use the <bbox-query/> directly inside the <query> block, like here: http://overpass-turbo.eu/s/7SK. That should work as expected. --Tyr (talk) 19:04, 25 February 2015 (UTC)
thanks :) --Trublu (talk) 06:58, 26 February 2015 (UTC)

GeoJSON output

Is there a way to send GeoJSON output on a search string? I am trying to build shapely Polygon objects from boundaries relation, and building the objects from JSON is very difficult. If I had a GeoJSON file I could try to build with the "Well Known Text" feature of python/shapely, building the entire Polygon with one command, instead of multiple loops which I have to do now. --Skippern (talk) 13:30, 14 March 2016 (UTC)

Wiki page ideas

Most discussion here is about overpass itself, but how about discussing the content of the Overpass API wiki page?

List of Overpass querying interfaces?

I came across Altryx's Overpass query interface just now. Seems neat. It made we wonder if we should list "querying interfaces" of Overpass API somewhere. Maybe a section on this wiki page.

Overpass turbo is the main one obviously. Very flexible, giving access to all/most API features. Then there's progressively less flexible systems. Alteryx and also my old XAPI query builder let you query by tags. The Query features tool on the main site is kind of an interface into the API. Then there's more end-user-app type things like thenextis.com which are very based on the overpass API, though not exactly presenting a "querying interface".

-- Harry Wood (talk) 13:38, 13 May 2016 (UTC)

Don't speak about "thenextis.com": it is simply unisable as you cannot select the search area (it only uses a very broad geolocalisation of the user by its IP, and in my case it does not even locate me in the correct area, I cannot look for anything in my area (all results are only more than 200 km away). I think this service works only for mobile user (geolocated more precisely), or for users living in large cities where ISPs are operating some regional NOC. This site also has no visible contact form or any visible address to some forum in case of problems... It is then only experimental for limited use, and the choice of queries is extremely limited (only those that the author wanted to look for in his own area). It cannot replace the Overpass API which has much more uses (including for contributors or project maintenance, when the default OSM.org Mapnik map is not enough, or existing QA tools cannot provide all searches needed). — Verdy_p (talk) 20:26, 26 July 2016 (UTC)

Move "advanced examples"?

IMHO the advanced examples are now out of place on this page. To keep this page simpler, I propose to move these to a separate page. Bjohas (talk) 16:29, 2 July 2016 (UTC)

I agree - Overpass_API/Advanced_examples seems obvious. The wiki pages need general cleanup - probably the maintainers have more fun programming ;)--Jojo4u (talk) 20:58, 21 October 2016 (UTC)

Switch to return also invisible objects

Hi!

Is it possible to retrieve information about an invisible (deleted) object so that e.g.

node(id:322918555,322918556);out meta;

returns something similar to

https://api.openstreetmap.org/api/0.6/nodes?nodes=322918555,322918556

Node 322918555 has the status visible="false". The OSM api call returns information for both nodes, esp. the version and Overpass API doesn't.

—Preceding unsigned comment added by GerdP (talkcontribs)

"no changeset-based criteria" limitation still accurate?

Overpass API#Limitations says:

Overpass API doesn't offer changeset-based criteria.

However Overpass API/Overpass QL lists several changeset-related filters like newer, changed, user and uid. So is that limitation still accurate or what is meant by "changeset-based criteria"?

It's possible to work around that, by using time-based diffs, but this may be clumsy.

I guess that refers to Overpass API/Augmented Diffs? That page should probably be linked somewhere from Overpass API, otherwise people are unlikely to find it.

Overpass API also can't give you full history of an object, but time-based selection criteria can give you the state of an object at a certain time. (this is supported since version 0.7.55 via retro and timeline, see Sliced Time and Space for more details).

Struck text is very hard to read, that sentence should just be updated to reflect the status quo. If it no longer fits in the Limitations section perhaps these notes about changeset/time-related querying should be moved to a different section?

--Push-f (talk) 20:29, 23 June 2022 (UTC)

"newer, changed, user and uid" - it will still fail to distinguish two edits by the same user made on the same second Mateusz Konieczny (talk) 09:53, 26 June 2022 (UTC)
Changeset-based criteria in this case refers to changeset metadata, which are published through the https://planet.openstreetmap.org/replication/changesets/ endpoint. Most fields returned by https://api.openstreetmap.org/api/0.6/changeset/122633092 cannot be used in a an Overpass query. This includes created_at, closed_at, open, the changeset bounding box, comments_count, changes_count, and all key/values pairs. —Preceding unsigned comment added by Mmd (talkcontribs)

https://maps.mail.ru/osm/tools/overpass/api/interpreter

https://maps.mail.ru/osm/tools/overpass/api/interpreter - is it actually working for someone? I run basic tests and it just fails (though not explored much) Mateusz Konieczny (talk) 15:52, 24 March 2023 (UTC)

Quick Start is not working

The Quick_Start section says that the code can run in the console of any modern browser. This is no longer the case.

Google Chrome Version 118.0.5993.118 for Windows shows the following errors:

   VM42:1 
       POST https://overpass-api.de/api/interpreter net::ERR_FAILED
   (anonymous) @ VM42:1
   VM42:2 Uncaught TypeError: Failed to fetch
       at <anonymous>:1:20
   (anonymous) @ VM42:1

Mozilla Firefox 118.0.2 for Windows shows the following errors

   Content-Security-Policy: The page’s settings blocked the loading of a resource at https://overpass-api.de/api/interpreter (“default-src”). debugger eval code:4:24
   Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource.
       <anonymous> debugger eval code:4
       <anonymous> debugger eval code:25
   debugger eval code:4:25
       <anonymous> debugger eval code:25
       AsyncFunctionThrow self-hosted:856
       (Async: async)
       <anonymous> debugger eval code:25
       getEvalResult resource://devtools/server/actors/webconsole/eval-with-debugger.js:299
       evalWithDebugger resource://devtools/server/actors/webconsole/eval-with-debugger.js:209
       evaluateJS resource://devtools/server/actors/webconsole.js:949
       evaluateJSAsync resource://devtools/server/actors/webconsole.js:846
       makeInfallible resource://devtools/shared/ThreadSafeDevToolsUtils.js:103

--Zstadler (talk) 10:31, 27 October 2023 (UTC)

Quick Start not working: Debugging

That is strange. Right now it works for me on MacOS FireFox 118.0.2 and Opera (Chromium version:116.0.5845.188)

The error might be fixed by going to https://overpass-api.de/api/interpreter (ignoring the webpage that looks like an error message) and THEN opening up a browser console and pasting the quickstart code. If that works for everyone, the quickstart can be updated with additional instructions.

--Jeff.hykin 11:55, 27 October 2023 (UTC)

Thank you for your contribution. I have to say that I found the whole concept of adding javascript in your browser way too difficult as a "Quick Start". Since ages, users can put their query into the Overpass API Query form: https://overpass-api.de/query_form.html - which accomplishes pretty much the same purpose, but doesn't put the burden on a user to run some Javascript code where it was never intended to be run. Also, overpass turbo is way more convenient for the average user who probably wants to see something on a map. I would even suggest to remove the whole "Quick Start" section in its current form. I get the idea, but it's probably not suitable for a larger part of the audience.

--mmd (talk) 14:24, 27 October 2023 (UTC)

Oh, I'm actually really surprised by that and I see now there's two different user bases.

Usually API's intentionally don't have any graphical interface (the first sentence on the Wikipedia page for API is "An API is in contrast with a User Interface"), and if we search "best API's" and pick any of the results (Stripe, Spotify, Google Maps), they're all designed for raw data output.

That said, I'm glad to hear Open Street maps is different and that other people are taking advantage of API's! and I definitely don't want to get in their way! I wouldn't want to accidentally recommend raw output to anyone who doesn't want raw output.

On my end I had a very very hard time getting some form (ANY form) of programmatically-retrieved raw-data output, which is what I thought the whole point of the API was for. It took me two days of reading the docs just to barely get enough knowledge to make that quickstart. Comparitively, it takes about 30min to first-time-learn and get raw data from the Spotify API (which requires making an account and setting up AUTH tokens). I don't even use Javascript, I just put the Javascript example because a fully-functioning example in just one language is enough to quickly adapt it any other programming language (and Javascript is the most commonly known language).

So, to help both groups (normal people and devs), I split the quick start into two sections and put the human-friendly interactive one first. Let me know if you think that addresses your concern.

--Jeff.hykin 16:05, 27 October 2023 (UTC)

Initially, I was really confused by the example you had added, since I didn't realize you were struggling to even call the API from your own app. There's quite a number of libraries, wrappers and sample code etc. out there, and your statement was a bit of a surprise to me. Usually, we would expect people to use a proper user agent in the http header, take care of rate limiting, proper error handling, etc., rather than just trying the bare minimum code to fire off some request to the Overpass API.
Most of the "typical" OSM users would head to overpass turbo, and leverage the "wizard" to generate some query. For a good amount of use cases, that's really good enough, and there's no need to get familiar with all the Overpass QL details. More advanced users would start writing their own Overpass QL queries. No matter how sophisticated you are, you can always ask for help (you've probably noticed the extensive list of community support sites). community.osm.org is a good place for this.
I'm also a bit confused about the "The Programmatic Query Language (OverpassQL)" section you have added in your last edit. Essentially "Overpass QL" and "Overpass API Query Language" are the same thing. We used to have an XML based variant which is discouraged today (most of the newer features are incredibly difficult to read as XML). This made me wonder, if you're talking about the pretty-printed version of QL? It would be better here to use existing terminology, rather than inventing something new, where it's not clear what it means. mmd (talk) 18:18, 27 October 2023 (UTC)