JSPM

@curium.rocks/openweathermap-client

0.281.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q115634F
  • License MIT

A typescript client for the OpenWeatherMap APIs

Package Exports

  • @curium.rocks/openweathermap-client
  • @curium.rocks/openweathermap-client/build/src/lib.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@curium.rocks/openweathermap-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

openweathermap-client

Quality Gate Status Security RatingCoverage

A typescript OpenWeatherMap client, API docs located here.

APIs supported.

  • OneCall
  • Pollution
  • CurrentWeather

API documentation for this library can be found here

Example(s)

import axios from "axios";
import {OwmClient} from '@curium.rocks/openweathermap-client';

const apiToken = process.env.OWM_TOKEN;
const owmClient = new OwmClient(axios);

const currentWeather = await owmClient.current.getCurrentWeather({
    appid: apiToken,
    city: 'London'
});

console.log('The current weather in London: ', currentWeather);

const currentWeatherNearArea = await owmClient.current.getCurrentWeatherNearby({
    appid: apiToken,
    lat: 29.422789,
    lon: -98.507065,
    cnt: 50
});

console.log('The current weather for areas nearby: ', currentWeatherNearArea);

const currentWeatherInRegion = await owmClient.current.getCurrentWeatherForArea({
    appid: apiToken,
    bbox: [
        {
            lat: 41.76106,
            lon: -89.45617,
        },
        {
            lat: 42.69255,
            lon: -85.94055
        }
    ]
});

console.log('The current weather data for the bounding area: ', currentWeatherInRegion);

const currentPollution = owmClient.pollution.getCurrentAirPollution({
    appid: apiToken,
    lat: 41.76106,
    lon: -85.94055
});
console.log('The current pollution levels: ', currentPollution);

const forecastedPollution = await owmClient.pollution.getForecastedAirPollution({
    appid: apiToken,
    lat: 41.76106,
    lon: -85.94055
});
console.log('The forecasted air pollution levels: ', forecastedPollution);

const historicalPollution = await owmClient.pollution.getHistoricalAirPollution({
    lat: 41.76106,
    lon: -85.94055,
    start: new Date(new Date().getDate()-1),
    end: new Date(),
    appid: apiToken
});
console.log('The pollution levels for the past day: ', historicalPollution);

const allInOne = await owmClient.onecall.getDate({
    lat: 41.76106,
    lon: -85.94055,
    appid: apiToken
});
console.log('The combined summary data is: ', allInOne);