Socket
Socket
Sign inDemoInstall

dark-sky-api

Package Overview
Dependencies
6
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dark-sky-api

A simple dark sky api wrapper for client side js supporting use of proxy and using method chaining and promises


Version published
Weekly downloads
28
increased by115.38%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

dark-sky-api

Based on Elias Hussary's dark-sky.

A wrapper library for Dark Sky API (previously known as Forecast.io). See Dark Sky developer docs: https://darksky.net/dev/docs.

Install it

 npm install dark-sky-api

Require it

import darkSkyApi from 'dark-sky-api';

Initialize it

While dark-sky-api allows embedding api keys through use of jsonp on the backend using a proxy to make the api call is highly suggested as this hides the API key from client side requests [ref].

  • proxy url is optional
  • pass an empty string or false for api key if using proxy url
const darkSky = new darkSkyApi('your-dark-sky-api-key', '//base-url-to-proxy/service');

Use it

darkSky.latitude(lat)
  .longitude(long)
  .get();
  .then(data => console.log(data));

Feel free to omit setting of latitude and longitude for subsequent calls i.e.:

const darkSky = new darkSkyApi('your-dark-sky-api-key');
darkSky.latitude(lat)
  .longitude(long);

darkSky.get();

Make use of excludes

"Exclude some number of data blocks from the API response. This is useful for reducing latency and saving cache space (see 'Request Parameters')."

const excludes = ['alerts', 'currently', 'daily', 'flags', 'hourly', 'minutely'],
  exludesBlock = excludes.filter(val => val != 'currently').join(',')
darkSky.latitude(lat)
  .longitude(long)
  .exclude(excludesBlock)
  .get()
  .then(data => console.log(data));

Keywords

FAQs

Last updated on 06 Apr 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc