1.1.0 • Published 6 years ago

fdarksky v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

FDarksky

This module is intended to be a wrapper for the Darksky weather API service.

Prerequisites

  • Node JS
  • NPM
  • Valid Darksky API key

Installation

npm install fdarksky --save

Usage

Include fdarksky into your project

const ds = require('fdarksky')

Set Configuration

ds.SetConfig({apiKey: Darksky API key<String>, options: Darksky options<Object><Optional>})

Basic Configuration Example

ds.SetConfig({apiKey: 'qwertyuiop1234567890'})

Get Weather Data

ds.Get(latitude<Number>, longitude<Number>)

Example GET

ds.Get(42.3601, -71.0589)
	.then(response => console.log(response))
	.catch(error => console.log(error))

Example Response

{ status: 'OK',
  response:
   { latitude: 42.3601,
     longitude: -71.0589,
     timezone: 'America/New_York',
     currently:
      { time: 1515257634,
        summary: 'Clear',
        icon: 'clear-day',
        nearestStormDistance: 27,
        nearestStormBearing: 219,
        precipIntensity: 0,
        precipProbability: 0,
        temperature: 9.94,
        apparentTemperature: -2.85,
        dewPoint: -5.61,
        humidity: 0.48,
        pressure: 1013.77,
        windSpeed: 9,
        windGust: 20.55,
        windBearing: 281,
        cloudCover: 0,
        uvIndex: 1,
        visibility: 10,
        ozone: 402.36 },
     minutely:
      { summary: 'Clear for the hour.',
        icon: 'clear-day',
        data: [Array] },
     hourly:
      { summary: 'Partly cloudy starting this evening.',
        icon: 'partly-cloudy-night',
        data: [Array] },
     daily:
      { summary: 'Rain on Friday and next Saturday, with temperatures rising to 52°F on Friday.',
        icon: 'rain',
        data: [Array] },
     alerts: [ [Object] ],
     flags: { sources: [Array], 'isd-stations': [Array], units: 'us' },
     offset: -5 } }

Optional Request Parameters

exclude: <Array:String>

Exclude some number of data blocks from the API response. This is useful for reducing latency and saving cache space. The available options are...

  • currently
  • minutely
  • hourly
  • daily
  • alerts
  • flags
lang: <String>

Return summary properties in the desired language. (Note that units in the summary will be set according to the units parameter, so be sure to set both parameters appropriately.) language may be:

  • ar: Arabic
  • az: Azerbaijani
  • be: Belarusian
  • bg: Bulgarian
  • bs: Bosnian
  • ca: Catalan
  • cs: Czech
  • da: Danish
  • de: German
  • el: Greek
  • en: English (which is the default)
  • es: Spanish
  • et: Estonian
  • fi: Finnish
  • fr: French
  • hr: Croatian
  • hu: Hungarian
  • id: Indonesian
  • is: Icelandic
  • it: Italian
  • ja: Japanese
  • ka: Georgian
  • kw: Cornish
  • nb: Norwegian Bokmål
  • nl: Dutch
  • pl: Polish
  • pt: Portuguese
  • ro: Romanian
  • ru: Russian
  • sk: Slovak
  • sl: Slovenian
  • sr: Serbian
  • sv: Swedish
  • tet: Tetum
  • tr: Turkish
  • uk: Ukrainian
  • x-pig-latin: Igpay Atinlay
  • zh: simplified Chinese
  • zh-tw: traditional Chinese
units: <String>

Return weather conditions in the requested units. Units should be one of the following:

  • auto: automatically select units based on geographic location
  • ca: same as si, except that windSpeed and windGust are in kilometers per hour
  • uk2: same as si, except that nearestStormDistance and visibility are in miles, and windSpeed and windGust in miles per hour
  • us: Imperial units (the default)
  • si: SI units

SI units are as follows:

  • summary: Any summaries containing temperature or snow accumulation units will have their values in degrees Celsius or in centimeters (respectively).
  • nearestStormDistance: Kilometers.
  • precipIntensity: Millimeters per hour.
  • precipIntensityMax: Millimeters per hour.
  • precipAccumulation: Centimeters.
  • temperature: Degrees Celsius.
  • temperatureMin: Degrees Celsius.
  • temperatureMax: Degrees Celsius.
  • apparentTemperature: Degrees Celsius.
  • dewPoint: Degrees Celsius.
  • windSpeed: Meters per second.
  • windGust: Meters per second.
  • pressure: Hectopascals.
  • visibility: Kilometers.

Example

const reqOptions = {
    units: 'si',
    lang: 'en',
    exclude: ['minutely', 'hourly', 'daily']
}

ds.SetConfig({options: reqOptions})

ds.Get(42.3601, -71.0589)
    .then(response => console.log(response))

Links

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago