Automating OS OpenData downloads
Last updated
Last updated
This guide takes you though the process of automating the download of OS OpenData downloads.
A basic understanding of automatic processing of JSON data and basic procedural (if-then-else) programming.
A text editor like Visual Studio Code
Please read the download support documentation before working with data packages.
These are generic instructions intended to broadly outline the necessary steps. Please see Sample implementation using Node.js below for one possible implementation.
Get the list of products available from endpoint including the product id
and version
.
This is similar to a manual download in that you first need to discover what is available. Be mindful that list items can change.
Each entry in the JSON response provides the Name
, Description
, Version
, URL
and ID
.
You may at this point wish to create a loop that iterates through all available datasets or a subset that you are interested in based on common attributes (for example, vector data in a certain format).
You could store the product id and version. That way you can easily check periodically for new versions of the data being available, simply by comparing the version we provide with the one you hold.
Using the product id from the previous response make a call to the endpoint.
This will result in a list of all available download links. This may be a single link for some datasets or a set of links split by area covered and/or formats supplied.
Once you obtain the download link for the area of the dataset in the format you require you are ready to download the data, ready for automated processing by whichever means your system requires.
In this example we hard code the product and format we are interested in (OpenGreenspace in ESRI® Shapefile). This can also be provided dynamically into the function allowing the same function to be used for multiple products and formats.