I'm calling this:


And I have a result that is correct, since it shows me the only hospital in the area. Then, following the instructions explained in this answer, I've modified the call like this:


With this I do not have the same result, since "elements" is empty, like there is no hospital in the area. If I remove the "amenity=hospital" filter, I do have correct nodes from the area selected (but still, not the hospital!), so why the results are different?

Also, If I wanted to use the first solution, how could I read the xapi file I get? (I'm using angular for a web app)


1 Answer 1


Both calls are not equivalent! While the XAPI call returns nodes, ways and relations, your second query example only returns nodes. However, all hospitals in your bounding box are modelled as OSM ways, hence you won't get any result. This works as expected and is not a bug, your query just didn't ask for any OSM ways.

As XAPI is completely dead by now and discouraged to be used in new projects, I'd recommend to create some example query in Overpass QL via overpass turbo wizard:

  1. Head to http://overpass-turbo.eu
  2. click on Wizard
  3. Enter amenity=hospital in the popup window and create a query

This way you can create a suitable query including nodes, ways and relations. If you don't like JSON output, replace [out:json] by [out:xml] at the top of the generated query.

Export -> raw data directly from Overpass API will give you a suitable link to use in your app. Adjust the bounding box in there as needed.

  • Thanks for the explanation. What I would like is to create custom queries based on what the user wants, that means that in this specific example the amenity is "hospital", but one can modify it according to his preferences (ex: amenity=bar). Then, how can I query the service from a web app? Now I have this wizard and I can get my datas, but what I need is that I can retrieve data from this service directly from my app, and show them to the user according to his preferences.
    – TodorokiM
    Aug 12, 2017 at 13:16
  • You can use the wizard to get familiar with the Overpass QL language and use the generated query as a template for your own query. I think you should take a look at existing projects like github.com/dotevo/osm24 or github.com/marczoutendijk/openpoimap which already implement what you're looking for.
    – mmd
    Aug 12, 2017 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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