eliashussary / dark-sky Goto Github PK
View Code? Open in Web Editor NEWA dead simple Dark Sky API wrapper for Nodejs using method chaining and promises.
Home Page: https://darksky.net/dev/docs
A dead simple Dark Sky API wrapper for Nodejs using method chaining and promises.
Home Page: https://darksky.net/dev/docs
While 0
inputs are rare, they are valid for all three methods and should be set. (0 degrees latitude is the equator; 0 degrees longitude is the prime meridian; and a 0 timestamp is the Unix Epoch.)
It appears that when you call coordinates, it is assigning the lng
param to this.lng
instead of this.long
.
Submitted a PR.
I'm passing the time
option and receiving back daily data with UNIX times that are in 1970.
const moment = require('moment');
const DarkSky = require('dark-sky')
const darksky = new DarkSky(DARKSKY_KEY)
exports.weather = (req, res) => {
try {
const body = JSON.parse(req.body);
const { lat, lng, time, units } = body;
const promises = [];
for (var i = 7; i > 0; i--) {
promises.push(darksky
.options({
latitude: lat,
longitude: lng,
time: moment(time).subtract(i, 'days'),
language: 'en',
units: units || 'auto',
exclude: ['minutely', 'hourly']
})
.get()
.then((val) => {
return val;
})
.catch(console.log))
}
Promise.all(promises).then((result) => {
res.status(200).json(result);
});
} catch (err) {
next(err)
}
};
Here's what I get back for one of the daily datasets:
{
"time": 1517212800,
"summary": "Clear throughout the day.",
"icon": "clear-day",
"sunriseTime": 1517237600,
"sunsetTime": 1517275281,
"moonPhase": 0.44,
"precipIntensity": 0,
"precipIntensityMax": 0,
"precipProbability": 0,
"temperatureHigh": 85.54,
"temperatureHighTime": 1517266800,
"temperatureLow": 63.27,
"temperatureLowTime": 1517320800,
"apparentTemperatureHigh": 85.54,
"apparentTemperatureHighTime": 1517266800,
"apparentTemperatureLow": 63.27,
"apparentTemperatureLowTime": 1517320800,
"dewPoint": 26.57,
"humidity": 0.19,
"pressure": 1018.59,
"windSpeed": 3.63,
"windGust": 12.78,
"windGustTime": 1517234400,
"windBearing": 34,
"cloudCover": 0.02,
"uvIndex": 4,
"uvIndexTime": 1517256000,
"visibility": 10,
"ozone": 298.78,
"temperatureMin": 61.35,
"temperatureMinTime": 1517223600,
"temperatureMax": 85.54,
"temperatureMaxTime": 1517266800,
"apparentTemperatureMin": 61.35,
"apparentTemperatureMinTime": 1517223600,
"apparentTemperatureMax": 85.54,
"apparentTemperatureMaxTime": 1517266800
}
new Date(1517212800) // Sun Jan 18 1970 05:26:52 GMT-0800 (PST)
Is there a way to choose in which unit data will be returned?
Hi,
As Apple is cutting off the DarkSky API for web usage and moving it to WeatherKit, could you possibly move to Pirate Weather, which is created as a "drop in" replacement?
It takes a single line change:
https://github.com/eliashussary/dark-sky/blob/master/dark-sky-api.js#L125
From:
api.darksky.net
to api.pirateweather.net
Verified everything on local end works perfectly with this change.
Also -- could you potentially re-publishing the nodejs module as pirate-weather
?
{moonPhase: 0.4 precipType: "rain" pressure: 1011 pressureError: 3.7 summary: "Partly cloudy throughout the day."}
above shows the part of the response and "precipIntensity" is not there.
Forecast.io was recently renamed to Dark Sky (.net), and as such, the API end point as changed, as well as some minor/non-breaking (from first glance) changes.
Refer to the new documentation (finally!) for details:
https://darksky.net/dev/docs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.