Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
SimpleSky is a promise based, intuitive, and data friendly API Wrapper for Dark Sky. With natural language recognition SimpleSky removes the need to painstakingly acquire manual coordinates to retrieve weather information.
npm install simplesky --save
npm test
Before getting started you'll need to acquire both a Google Maps API Key as well as a Dark Sky API Key.
Once acquired simply create a SimpleSky object and you'll be set up.
const simplesky = require('simplesky');
var weather = new simplesky('YOUR GOOGLE MAPS KEY', 'YOUR DARK SKY KEY');
Optionally if you would like to set your language and unit defaults (as specified in the Dark Sky API Documentation) for all responses you can do so here as well. By default SimpleSky will return all responses in English and weather units based on geographic location.
var weather = new simplesky('YOUR GOOGLE MAPS KEY', 'YOUR DARK SKY KEY', 'zh');
//Alternatively, you can force certain units for all responses
var weather = new simplesky('YOUR GOOGLE MAPS KEY', 'YOUR DARK SKY KEY', 'x-pig-latin','uk2');
SimpleSky is a complete wrapper for the Dark Sky API, anything you can do with the API you can do here and without headache. SimpleSky is also completely promise based so your code stays clean and easy to read.
All methods within SimpleSky allow for either natural language location input or precise latitude/longitude coordinate input to retrieve JSON formatted weather data.
Here's a simple example in which we print out the current temperature for our local Pizza Hut in Mongolia
weather.getCurrently('Pizza Hut Mongolia').then((response) => {
console.log(response.temperature);
}).catch((error) => {
console.log(error);
});
Alternatively, if you're already working with software in which you get a user's geolocation data, fear not, you can still take advantage of all of SimpleSky's features.
weather.getCurrently(null, 37.0326, -95.6188).then((response) => {
console.log(response.temperature);
}).catch((error) => {
console.log(error);
});
SimpleSky allows you to customize the weather output the Dark Sky API returns to help save you additional cache space. To do so will require taking advantage of the getWeather()
method.
SimpleSky uses the exact same naming scheme used in the Dark Sky API documentation. So in order to remove certain blocks from the weather output, we simply pass them in with the same names.
Once again, all methods within SimpleSky accept longitude and latitude input.
//Remove the alerts and flags blocks from the weather output
weather.getWeather("Pirates Museum Madagascar", null, null, ['alerts', 'flags']).then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
If you would like to isolate only a single block, methods have already been written that exclude all irrelevant data.
For reference these are
getCurrently();
getMinutely();
getHourly();
getDaily();
getFull();
//NOTE: Not all locations output minutely and hourly data
To see weather data for a date far into the future or into the past simply use the getTimeMachine()
method.
Specifying the time of your request couldn't be easier. Simply pass in your offset in the following format as a single string
'[+/-] {years}Y {months}M {weeks}w {days}d {hours}h {minutes}m {seconds}s {milliseconds}ms'
To see the weather data for a certain location three years and two months from now simply do the following.
weather.getTimeMachine("Brooklyn Bridge", "+3y +2M").then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
Alternatively, if you would rather get data for a specific time as opposed to getting data from an offset you can do so from this method as well. Simply replace the offset with a UNIX timestamp to get weather data for that specific time.
weather.getTimeMachine("Brooklyn Bridge", 255657600).then((response) => {
console.log(response);
}).catch((error) => {
console.log(error);
});
Similar to the getWeather()
method, getTimeMachine()
also has an exclude
field if you would like to isolate certain blocks from the response.
If you'd like to get the weather data for the next 168 hours as opposed to the next 48, simply do the following.
weather.getHourly("UT Austin", null, null, true).then((response) => {
console.log(response);
}).catch(error) =>{
console.log(error);
});
It's also possible to use SimpleSky to leverage the Google Maps API to get coordinate data for any location. Data is returned as a JSON object with lat
and lng
fields.
weather.getCoordinates('North Pole').then((response) => {
console.log(response.lat);
console.log(response.lng);
}).catch((error) => {
console.log(error);
});
FAQs
The easiest, promise-based Dark Sky API Wrapper designed for Node.js
The npm package simplesky receives a total of 0 weekly downloads. As such, simplesky popularity was classified as not popular.
We found that simplesky demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.