I have looked into the forecast io (Darksky) api document, and find there are options that can change the temperature to celsius. I'm not sure how to use the code they provided.
Thanks for your help!
You can add the si units options to your parameters in the request. This should give you back temperature in celsius. For example:
const https = require('https');
var body = "";
const url = "https://api.darksky.net/forecast/your-key-goes-here/53.34929607,-6.26036167?units=si"
var req = https.request(url, (res) => {
res.on('data', (d) => {
body += d;
});
res.on('end', () => {
var data = JSON.parse(body);
console.log(data.currently.temperature);
});
});
req.on('error', (e) => {
console.error(e);
});
req.end();
I hope this helps.
for dark sky API :
https://api.darksky.net/forecast/5dc71e8b06915dee1cac240d5805eb66/24.68,83.06?units=si&exclude=hourly,flags,offset
For Retrofit :
//https://api.darksky.net/forecast/5dc71e8b06915dee1cac240d5805eb66/24.68,83.06?units=si
@GET("/forecast/{apikey}/{latitude},{longitude}?")
Call <SkyWeatherAPI> getWeatherDarkSky(@Path("apikey") String apikey, @Path("latitude") String latitude,
@Path("longitude") String longitude, @Query("units") String units);
Call apiWeatherCall = mApiWeather.getWeatherDarkSky(API_KEY, "24.68","83.06", "si");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With