How do I retrieve weather data using an ODATA request?

This article describes how to retrieve weather data such as weather forecast, historical weather observations and historical climate summaries using an ODATA bahttps://www.visualcrossing.com/resources/documentation/weather-api/building-and-running-your-first-weather-api-query/sed request.

What is ODATA and when should I use it?

According to odata.org:

OData (Open Data Protocol) is an ISO/IEC approvedOASIS standard that defines a set of best practices for building and consuming RESTful APIs. OData helps you focus on your business logic while building RESTful APIs without having to worry about the various approaches to define request and response headers, status codes, HTTP methods, URL conventions, media types, payload formats, query options, etc. 

ODATA is therefore a convenient way to retrieve structured data like grids or tables of information such as weather data sets. The tools you use may provides a simple way to import data from ODATA requests such as SAP Analytics Cloud. Supplying the weather data in this format therefore makes it quick and easy to import the weather data into the tool.

How to construct the weather data request

NOTE: the below steps refer to the legacy version of the web based query builder. Please switch to the legacy version as shown in the screenshot below. For sure you can construct the query yourself as well.

We are going to create a Visual Crossing Weather API query. From this query, we can request a pre-built request in ODATA format.

The easiest way to construct the weather data request is to use the Weather Data Services page to construct the query. From here you can set the locations to pull data for, choose type of weather data you are interested in, modify the parameters and view the data in the browser. You can also download the data directly into the browser.

For more information on signing up and creating your first Weather Data Services query in the weather API, please How do I get started with the Weather API?

When you have created a weather API link, you should see the following:

mceclip2.png

This is a sample of a Weather API query that will retrieve the weather forecast for a single location. 

Creating the ODATA link

By default the weather API queries are formatted as a GET based request. However you can also specify to format the request as a POST or ODATA request.

To create an ODATA request for the Weather Data, click switch to the ODATA format:

mceclip1.png

The resulting ODATA query completely encapsulates the requested weather data in a single ODATA request:

mceclip3.png

If you copy this query, you can use it directly in your tool. If you place the query into a browser address bar you will see the following output:

mceclip4.png

To retrieve the actual data, append /WxRequest to the of of the URL. Note that some tools will require the URL with the /WxRequest added and some, such as a SAP Analytics Cloud will prompt you.  When prompted you should choose the WxRequest option.

The final data when viewed in the browser, will resemble:

mceclip6.png

Please note that ODATA access is available only when using specific Visual Crossing Weather plans. To learn more about our plan options, please visit our Editions page. If you have additional questions or need help selecting the best plan for your use case, please reach out to us, and we’ll be glad to help.

To learn more about constructing the weather data request, please see Getting Started With Weather Data Services. To learn more about the Weather API, please see Weather API page.

Scroll to Top