How do I filter results within a bounding box?


I want to make a request to the server for all roads (everything of the highway type) for a given bounding box. Is there a way to do this with the API? I see the search function, but when I try and specify a bounding box I end up with nodes and ways from everywhere.

I am downloading data in tiles .03 degrees square and really only want the roads. The XML tiles are then cached on the client to reduce future server load. Is there an ideal size for data request tiles that will reduce the number of duplicate ways and nodes received?

Thanks for your help! We’re new to OSM, but really hope we’re able to make a splash.


You are looking for the OSM XAPI.

Thanks for the info, that’s what I was looking for. Unfortunately, after playing around with the xapi it seems that it’s much slower and more unreliable than just using the API and grabbing everything. Should this be the case? It’s really unfortunate, as I would rather grab just the data I need vs everything. The URL seems to be not working at all … server timeout every time I tried to go directly to it.


Well, if the amount of data is fairly small then it really doesn’t matter if the API is slow or not, but yet, the API is often slow because of it being hammered by all kinds of people/software of which the TilesAtHome client is probably the biggest culprit.

If you’re about to download more then, say, 25 Megabytes from the XAPI then you might want to check out the weekly database (planet) dump and extract (Osmosis) your data from that locally (or download a preprocessed planet extracts).

So if you want all the roads in a country in 0.3 degrees squares then download the country planet extract and process that with Osmosis (A lot of data). If you just want all the railway stations in a country then you can use the XAPI (a little amount of data).