Socket
Socket
Sign inDemoInstall

dark-sky-api

Package Overview
Dependencies
13
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 and robust dark sky api service for client-side js


Version published
Weekly downloads
28
increased by133.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

dark-sky-api

A simple and robust wrapper library for Dark Sky API (previously known as Forecast.io).

Features:

  • Simple to use.
  • Promise based (es6-promises).
  • Versatile - use it statically or instantiate it.
  • Dates returned as moments.
  • Excludes are used automatically to reduce latency and save cache space (see 'Request Parameters').

See Dark Sky developer docs: https://darksky.net/dev/docs.

Need something even smaller? Dark sky api uses dark-sky-skeleton.

Install it

 npm install dark-sky-api

Require it

import DarkSkyApi from 'dark-sky-api';

Configure it statically (suggested)

Configuring dark-sky-api with an api key is supported but each request will expose said api key (for anyone to capture).

For this reason Dark Sky strongly suggests hiding your API key through use of a proxy [ref].

// one of the two is required
DarkSkyApi.apiKey = 'your-dark-sky-api-key';
DarkSkyApi.proxyUrl = '//base-url-to-proxy/service';

// optional configuration
DarkSkyApi.units = 'si'; // default 'us'
DarkSKyApi.language = 'de'; // default 'en'

Use it

Today's weather:

DarkSkyApi.getCurrent()
  .then(result => console.log(result));

Forecasted week of weather:

DarkSkyApi.getForecast()
  .then(result => console.log(result));

What about geo location?

By default dark-sky-api will use Geolocation.getCurrentPosition to grab the current browser location automatically.

To manually set geolocation position pass along a position object:

const position = {
  latitude: 43.075284, 
  longitude: -89.384318
};
DarkSkyApi.getCurrent(position)
  .then(result => console.log(result));

Response units

To get the units used in dark sky api responses per configured unit type (default is 'us') use GetResponseUnits after configuration.

const units = DarkSkyApi.getResponseUnits();
To Do
  • show examples of instantiation
  • show example of using results with units
  • add hourly and minutely api methods
  • add flags and alerts apit methods

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