openweathermap-api-module
Simple Node module to call the openweathermap API
This wrapper is based on the free tier of OpenWeatherMap API. You can get your API key here.
Table of Contents
Install
$ npm install openweathermap-api-module
Usage
const OpenWeatherMapRequests = const apiKey = 'api key'const client = apiKey client
Check out the Openweathermap API documentation for more information!
API
Table of Contents
- constructor
- currentWeatherByCityName
- currentWeatherByCityName
- currentWeatherByCityId
- currentWeatherByGeoCoordinates
- currentWeatherByZipCode
- currentWeatherByRectangleZone
- currentWeatherByCircleZone
- currentWeatherByCityIds
- constructor
- getOneLocationByCityName
- getOneLocationByCityId
- getOneLocationByGeoCoordinates
- getOneLocationByZipCode
- getManyLocationsByRectangleZone
- getManyLocationsByCircleZone
- getManyLocationsByCityIds
constructor
Mixin for handling API requests options
Parameters
Examples
const client = ApiKey {}
currentWeatherByCityName
Call Current weather for One location by city Name
Parameters
args
Object Arguments for mixin handler
Examples
const client = API_KEYclientclient
Returns Object response - Object with data from request Type
currentWeatherByCityName
Mixin for handling API requests options
Parameters
args
currentWeatherByCityId
Call Current weather for One location by city ID
Parameters
args
Object Arguments for mixin handler
Examples
const client = API_KEYclientclient
Returns Object response - Object with data from request Type
currentWeatherByGeoCoordinates
Call Current weather for One location by Geographic Coordinates
Parameters
args
Object Arguments for mixin handler
Examples
const client = API_KEYclientclient
Returns Object response - Object with data from request Type
currentWeatherByZipCode
Call Current weather for One location by Zipcode
Parameters
args
Object Arguments for mixin handler
Examples
const client = API_KEYclientclient
Returns Object response - Object with data from request Type
currentWeatherByRectangleZone
Call Current weather for many locations by Rectangle Box
Parameters
args
Object Arguments for mixin handler
Examples
const client = API_KEYclientclient
Returns Object response - Object with data from request Type
currentWeatherByCircleZone
Call Current weather for many locations by Circle Radius
Parameters
args
Object Arguments for mixin handler
Examples
const client = API_KEYclientclient
Returns Object response - Object with data from request Type
currentWeatherByCityIds
Call Current weather for many locations by City Ids
Parameters
args
Object Arguments for mixin handler
Examples
const client = API_KEYclientclient
Returns Object response - Object with data from request Type
constructor
Current Weather API handler. Key is inherited from OpenWeatherMapRequests
Parameters
apiKey
baseUrl
baseUrl-null
String API base URL from OpenWeatherMap API
Examples
const client = 'Api_key''base_url'
getOneLocationByCityName
Call Current weather for One location by city Name
Parameters
Examples
// api.openweathermap.org/data/2.5/weather?q=London// api.openweathermap.org/data/2.5/weather?q=London,ukconst client = API_KEY BASE_URLclientclientclientclient
Returns Object requestResponse - Return Object from API call
getOneLocationByCityId
Call Current weather for One location by ID
Parameters
cityId
(String | Number) Id of the Cityargs
(optional, default{}
)options
Object? options for request
Examples
// api.openweathermap.org/data/2.5/weather?id=2643743const client = API_KEY BASE_URLclientclient
Returns Object requestResponse - Return Object from API call
getOneLocationByGeoCoordinates
Call Current weather for One location by Coordinates
Parameters
coordinates
Object Object including Coordinates. Ex: { lat: 139.01, lon: 35.02 }args
(optional, default{}
)options
Object? options for request
Examples
// api.openweathermap.org/data/2.5/weather?lat=35&lon=139const client = API_KEY BASE_URLclientclient
Returns Object requestResponse - Return Object from API call
getOneLocationByZipCode
Call Current weather for One location by Zip Codes
Parameters
zipCode
args
(optional, default{}
)zipcode
String Zipcode from Country, ex: 'zipcode,country' (optional, default"90247,us"
)options
Object? options for request
Examples
// api.openweathermap.org/data/2.5/weather?zip=94040,usconst client = API_KEY BASE_URLclient
Returns Object requestResponse - Return Object from API call
getManyLocationsByRectangleZone
Call current weather data for several cities using a Bounding Box bbox bounding box [lon-left,lat-bottom,lon-right,lat-top,zoom]
Parameters
bbox
Object Bounding Box for location. Example: bbox={ lonLeft: '0', latBottom: '0', lonRight: '0', latTop: '0', zoom: '0' }args
(optional, default{}
)options
Object? options for request
Examples
// api.openweathermap.org/data/2.5//box/city?bbox=12,32,15,37,10const client = API_KEY BASE_URLclientclient
Returns Object requestResponse - Return Object from API call
getManyLocationsByCircleZone
Call current weather data for several cities using a Longitude and Latitude and get all cities around it
Parameters
circle
Object Circle object with longitude, latitude and number of cities to show ex: { lat: 55.5, lon: 37, cnt: 10 }args
(optional, default{}
)options
Object? options for request
Examples
// api.openweathermap.org/data/2.5//box/city?lat=55.5&lon37.5&cnt=10const client = API_KEY BASE_URLclientclient
Returns Object requestResponse - Return Object from API call
getManyLocationsByCityIds
Call for several city IDs
Parameters
cityIds
args
(optional, default{}
)citiIds
Array Array filled with city IDs, ex: [524901,703448,2643743]options
Object? options for request
Examples
// http://api.openweathermap.org/data/2.5/group?id=524901,703448,2643743const client = API_KEY BASE_URLclientclient
Returns Object requestResponse - Return Object from API call