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

2

14

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
Archil answered 5/9, 2015 at 13:48 Comment(0)
N
22

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

Niveous answered 21/10, 2015 at 23:49 Comment(0)
E
2

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
Ernestinaernestine answered 30/6, 2018 at 12:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.