1

I try to make an Overpass API call with restricted number of tags, to achieve this I incorporated convert statement. Here is working overpass turbo example of query for data I would like to fetch:

[out:json][bbox:52.2,20.7,52.3,21.3];
node [amenity=drinking_water];
convert node
    ::id=id(),
    id=id(),
    lat=lat(),
    lon=lon(),
    access=t["access"],
    name=t["name"];
out;

Next i tried to make an URL call using this query like this:

https://overpass-api.de/api/interpreter?[out:json][bbox:52.2,20.7,52.3,21.3];node[amenity=drinking_water];convert%20node::id=id(),id=id(),lat=lat(),lon=lon(),access=t["access"],name=t["name"];out;

Unfortunatelly it throws parse error:

Error: line 1: parse error: Element class name expected - '%' found.

Error: line 1: parse error: Operator expected, but "node"found.

Error: line 1: parse error: Operator expected, but "access"found.

Error: line 1: parse error: Operator expected, but "name"found.

Error: line 1: parse error: "%" cannot be used as binary operator

Error: line 1: parse error: t[...] needs an argument

Error: line 1: parse error: "%" cannot be used as binary operator

Error: line 1: parse error: t[...] needs an argument

Error: line 1: parse error: if special character "%" is present in property name then the property name must be in quotes

Error: line 1: parse error: "=" cannot be used as binary operator

Error: line 1: static error: The attribute type must be set to a nonempty string.

I can see, that the problem (or one many) is with dividing convert element with space, but I don't know how to workaround it. Removing space between them results in parse error:

Error: line 1: parse error: Unknown type "convertnode"

2 Answers 2

1

You forgot to include "data=" in your example query, right after "interpreter?". The following will also work:

curl -g 'https://overpass-api.de/api/interpreter?data=[out:json][bbox:52.2,20.7,52.3,21.3];node[amenity=drinking_water];convert%20node::id=id(),id=id(),lat=lat(),lon=lon(),access=t["access"],name=t["name"];out;'
0

To make your life easier there is a method to convert your query directly to an URL. First click on "Export".

The Export button to click.

This gives you a dialog where you could simply copy the required URL (right-click on "Overpass API"):

The query as an API URL.

And this is the final URL: https://overpass-api.de/api/interpreter?data=%5Bout%3Ajson%5D%5Bbbox%3A52.2%2C20.7%2C52.3%2C21.3%5D%3B%0Anode%20%5Bamenity%3Ddrinking_water%5D%3B%0Aconvert%20node%0A%20%20%20%20%3A%3Aid%3Did%28%29%2C%0A%20%20%20%20id%3Did%28%29%2C%0A%20%20%20%20lat%3Dlat%28%29%2C%0A%20%20%20%20lon%3Dlon%28%29%2C%0A%20%20%20%20access%3Dt%5B%22access%22%5D%2C%0A%20%20%20%20name%3Dt%5B%22name%22%5D%3B%0Aout%3B

But don't ask me what the conversion rules are for that but calling that URL gives this JSON:

The final JSON.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.