Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the query parameters in the Dark Sky Forecast API ?(forecast.io)

I'm using the Dark Sky Forecast API to retrieve some weather information.

When I read the official doc, I found that the "option" section describes the usage of query parameters.

For example,

The API request may optionally be modified through the use of query parameters. It will respond to the following:

callback=[callback]: Return the API response as JSONP. Please use caution when using this, since exposing your API key to the public is a security hazard and, if abused, will result in the revokation of your API key. However, if developing a personal- or internal-use app, this is a convenient method of doing so.

units=[setting]: Return the API response in units other than the default Imperial units. In particular, the following settings are possible:

  • us: The default, as outlined above.

  • si: Returns results in SI units. In particular, properties now have the following units:

  • ...

I know how to get the weather information by take advantages of the call

 https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE

But I don't know how to combine the query parameters with it.

Any ideas?


2015/10/23 UPDATE

Thank to Logan Kearns, using ? parameter solved my question. Make sure the query parameters are in lowercase.

https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE?lang=zh-tw&units=si
like image 637
Carter Chen Avatar asked Sep 05 '15 13:09

Carter Chen


People also ask

Where does Dark Sky get their data from?

The app pulls real time radar data from the National Oceanic and Atmospheric Administration (NOAA)'s National Weather Service (NWS) which operates 140 doppler radar stations across the United States.

Is Dark Sky weather accurate?

About the Dark Sky Weather App Available only for iOS devices, the Dark Sky weather app has provided “the most accurate source of hyperlocal weather information” and “down-to-the-minute forecasts” since 2018.

How do I use the Dark Sky API to generate forecasts?

Using the Dark Sky API, there are two ways you can achieve this. You can either take the hourly or daily forecasts provided with the current forecast returned from the “GET Forecast” endpoint. Alternatively, if you want to consider a more extended range, then “GET Time Machine” is your best friend.

How do I visualize weather patterns in Dark Sky?

To visualize weather patterns, you first have to build a dataset to accumulate weather data for a range of days. Using the Dark Sky API, there are two ways you can achieve this. You can either take the hourly or daily forecasts provided with the current forecast returned from the “GET Forecast” endpoint.

How do I run a test run of the Dark Sky API?

It’s time to do a test run of the Dark Sky API. Select the “GET Forecast” endpoint within the API console. Enter the values for the ‘latitude and ‘longitude’ parameters as shown, and click the Test Endpoint button. This triggers the API to return the current forecast for New York City, as defined by the location coordinates.

How does the weather API work?

The weather API communicates the weather status as words like clear-day, clear-night, rain, snow, sleet, wind, fog, cloudy, partly-cloudy-day, or partly-cloudy-night. We have a folder with all these words as images.


Video Answer


2 Answers

This is how you change the units. I assume that other query parameters would be set in a similar manner, using the '?' to separate them.

https://api.forecast.io/forecast/APIKEY/LATITUDE,LONGITUDE?UNITS=us

like image 154
Laura Kearns Avatar answered Sep 20 '22 11:09

Laura Kearns


Just an update, since url changed and with few other parameters:

You can add units to mention the type of unit conversion required You can add exclude for excluding certain data in the response like hourly updates.

https://api.darksky.net/forecast/APIKEY/LAT,LONG?units=si&exclude=minutely,hourly,daily,alerts
like image 43
Psypher Avatar answered Sep 21 '22 11:09

Psypher