
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
openweathermap-ts
Advanced tools
An abstract layer over openWeatherMap APIs to simplify making calls. Built with TypeScript and Promises. Even the returned JSON responses are typed for your benefits!
Note: The library currently only supports free tier API services:
// install using npm
npm install openweathermap-ts
You will also need to register for an API key at the official site.
const OpenWeatherMap = require('openweathermap-ts');
// or
import OpenWeatherMap from 'openweathermap-ts';
const openWeather = new OpenWeatherMap({
apiKey: 'Your API Key'
});
There are 2 ways of using public getter methods.
When both are used, the argument/s precede over the defined location object.
Notice some methods are grouped together with & because their arguments are the same. But they produce different results.
/**
* @param {
* cityName: string,
* state?: string, // Spell it out. E.g, Texas
* countryCode?: CountryCodeType
* }
*/
openWeather
.getCurrentWeatherByCityName({
cityName: 'Cedar Park'
})
.then((weather) => console.log('Weather object is', weather));
// or async await example
try {
const weather = await openWeather.getThreeHourForecastByCityName({
cityName: 'Cedar Park',
state: 'Texas',
countryCode: 'US'
});
console.log('Weather object is', weather);
} catch (error) {
console.error('Error is ', error);
}
List of ISO 3166 CountryCodeType
/**
* @param cityId: number
*/
openWeather
.getCurrentWeatherByCityId(1835848)
.then((weather) => {
console.log('Weather object is', weather);
})
.catch((error) => console.error('Error is ', error));
Or
// set the cityId in location object
openWeather.setCityId(1835848);
// invoke the method without an argument
openWeather
.getThreeHourForecastByCityId()
.then((weather) => {
console.log('Weather object is', weather);
})
.catch((error) => console.error('Error is ', error));
List of CityIds
/**
* @params latitude: number, longitude: number
*/
openWeather
.getCurrentWeatherByGeoCoordinates(33.426971, -117.611992)
.then((weather) => console.log('Weather object is', weather));
/**
* @params zipcode: number, countryCode?: CountryCodeType
*/
openWeather
.getCurrentWeatherByZipcode(84604)
.then((data) => console.log('Weather object is', data));
Or
openWeather
.getCurrentWeatherByZipcode(84604, 'US')
.then((data) => console.log('Weather object is', data));
List of CountryCodeType
/**
* @param apiKey: string
*/
openWeather.setApiKey('yourApiKey');
/**
* @param units: 'imperial'| 'metric' | 'standard' (Kelvin)
*/
openWeather.setUnits('metric');
/**
* @param language: LanguageTypes
*/
openWeather.setLanguage('kr');
// LanguageTypes List -> https://github.com/shimphillip/openweathermap-ts/blob/master/languages.md
/**
* @param none
*/
openWeather.getAllSettings();
/**
* @param none
*/
openWeather.clearSettings(); // Remember to reset your API Key
/**
* @param cityId: number
*/
openWeather.setCityId(1835848);
/**
* @param {
* cityName: string,
* state?: string, // (optional) Spell it out. E.g, Texas
* countryCode?: CountryCodeTypes // (optional)
* }
*/
openWeather.setCityName({
cityName: 'Austin'
});
// List of CountryCodeTypes https://github.com/shimphillip/openweathermap-ts/blob/master/src/helpers/country-codes.ts
/**
* @params latitude: number, longitude: number
*/
openWeather.setGeoCoordinates(33.426971, -117.611992);
/**
* @params zipcode: number, countryCodeTypes?: string (optional)
*/
openWeather.setZipCode(84604, 'US');
// List of CountryCodeType https://github.com/shimphillip/openweathermap-ts/blob/master/src/helpers/country-codes.ts
/**
* @param none
*/
openWeather.getAllLocations();
/**
* @param none
*/
openWeather.clearLocation();
Current Weather API: https://openweathermap.org/current 5 day / 3 hour Forecast API: https://openweathermap.org/forecast5
Please create issues or pull requests at https://github.com/shimphillip/openweathermap-ts
Love what you use? Buy me a coffee boba!🍹
FAQs
An abstract layer over openWeatherMap APIs
The npm package openweathermap-ts receives a total of 238 weekly downloads. As such, openweathermap-ts popularity was classified as not popular.
We found that openweathermap-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.