0.1.3 • Published 5 years ago

@lszanata/climate v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

climate

Build Status codecov

A simple JavaScript library for weather information.

Weather data is fetched from APIXU.

Usage

const climate = require( './' );

// Supply your API key
climate.init( 'YOUR_API_KEY' );

// Pass a location's latitude and longitude, in decimal degrees
// Middle of London
const result = await climate.getTemperature( 51.513214, -0.094938 )

climate returns a Promise, which resolves to a object with weather information, like this:

{
  location: 'London, City of London, Greater London, United Kingdom',
  coordinates: {
    latitude: 51.51,
    longitude: -0.09
  },
  temperature: {
    current: 10,
    apparent: 10,
    min: 7.7,
    max: 14
  }
}
// You can also pass a string with a location name
await climate.getTemperature( 'los angeles' );

// will return
{
  location: 'Los Angeles, California, United States of America',
  coordinates: {
    latitude: 34.05,
    longitude: -118.24
  },
  temperature: {
    current: 18.9,
    apparent: 18.9,
    min: 15.6,
    max: 22.3
  }
}

In case of an error, climate resolves to an error. For example:

await climate.getTemperature( 'tatooine' );

// Will throw
{
  error: {
    code: 1006,
    message: 'No matching location found.'
  }
}

Temperatrue information is given in degrees Celsius.

License

MIT

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago