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

Carter Chen picture Carter Chen · Sep 5, 2015 · Viewed 12.7k times · Source

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

Answer

Laura Kearns picture Laura Kearns · Oct 22, 2015

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