So far we've only dealt with data in OpenStreetMap XML files, but Osmosis can handle other sources of data, including databases and the OpenStreetMap API itself. Note that this is not the same as reading and writing to a database in API format, which we'll cover later.
Osmosis only supports the map call of the API to download data. We can get the data of Compton—the village we mapped in earlier chapters—and save it to a file using the read API task, as follows:
osmosis --read-api left="-0.64" bottom="51.21" right="-0.615" top="51.22" --write-xml file="compton.osm"
We supply the bounding box we want to download as four parameters to the read API task.
However, remember that the main API only allows you to download a limited area, so if you need a large area, this method won't work. Fortunately, you can also get Osmosis to retrieve data from XAPI by supplying its URL as another parameter. If we wanted to retrieve data of Iceland from XAPI within Osmosis...