This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Working with Current weather data in OpenWeatherMap
Overview
The following operations allow you to work with current weather data. Click an operation name to see details on how to use it.
For a sample proxy service that illustrates how to work with contacts, see Sample configuration.
Operation | Description |
---|---|
Get current weather data for one location by city ID. | |
Get current weather data for one location by city Name or city Name and country Code. | |
Get current weather data for one location by geographic coordinates. | |
Get current weather data for one location by zip code. | |
Get all current weather data for several cities within definite circle. | |
Get all current weather data for several cities within the defined rectangle. | |
Get current weather data for several city IDs. | |
Returns exact match values and returns results by searching for that substring. |
Operation details
This section provides further details on the operations related to current weather data.
Get Current weather for one location by City ID
The getCurrentWeatherForOneLocByCityID operation Returns the data from city by using City ID.
<openweathermap.getCurrentWeatherForOneLocByCityID> <cityID>{$ctx:cityID}</cityID> </openweathermap.getCurrentWeatherForOneLocByCityID>
Properties
- cityID:The ID of the City.
Sample request
Following is a sample REST/JSON request that can be handled by the getCurrentWeatherForOneLocByCityID operation.
{ "apiUrl":"http://api.openweathermap.org", "apiKey":"927d09bc49dbee6aac7f5cb1df707542", "apiVersion":"2.5", "cityID":"4740157" }
Related OpenWeatherMap documentation
http://openweathermap.org/current#one
Get current weather for one location by City name
The getCurrentWeatherForOneLocByCityName operation returns the data from city by using City name.
<openweathermap.getCurrentWeatherForOneLocByCityName> <cityName>{$ctx:cityName}</cityName> <countryCode>{$ctx:countryCode}</countryCode> </openweathermap.getCurrentWeatherForOneLocByCityName>
Properties
- cityName: The name of the City.
- countryCode: The code of the Country.
Sample request
Following is a sample REST/JSON request that can be handled by the getCurrentWeatherForOneLocByCityName operation.
{ "apiUrl":"http://api.openweathermap.org", "apiKey":"927d09bc49dbee6aac7f5cb1df707542", "apiVersion":"2.5", "cityName":"Washington", "countryCode":"us" }
Related OpenWeatherMap documentation
http://openweathermap.org/current#one
Get current weather for one location by geographic coordinates
The getCurrentWeatherForOneLocByGeoCoordinates operation returns the data from city by using geographic coordinates.
<openweathermap.getCurrentWeatherForOneLocByGeoCoordinates> <lon>{$ctx:lon}</lon> <lat>{$ctx:lat}</lat> </openweathermap.getCurrentWeatherForOneLocByGeoCoordinates>
Properties
- lon: City geographic location, longitude.
- lat: City geographic location, latitude.
Sample request
Following is a sample REST/JSON request that can be handled by the getCurrentWeatherForOneLocByGeoCoordinates operation.
{ "apiUrl":"http://api.openweathermap.org", "apiKey":"927d09bc49dbee6aac7f5cb1df707542", "apiVersion":"2.5", "lat":"35", "lon":"139" }
Related OpenWeatherMap documentation
http://openweathermap.org/current#one
Get current weather for one location by ZIP code
The getCurrentWeatherForOneLocByZipCode operation returns the data from city by using zip code.
<openweathermap.getCurrentWeatherForOneLocByZipCode> <zipCode>{$ctx:zipCode}</zipCode> <countryCode>{$ctx:countryCode}</countryCode> </openweathermap.getCurrentWeatherForOneLocByZipCode>
Properties
- zipCode: The Zipcode of city.
- countryCode: The code of the country.
Sample request
Following is a sample REST/JSON request that can be handled by the getCurrentWeatherForOneLocByZipCode operation.
{ "apiUrl":"http://api.openweathermap.org", "apiKey":"927d09bc49dbee6aac7f5cb1df707542", "apiVersion":"2.5", "zipCode":"94040", "countryCode":"us" }
Related OpenWeatherMap documentation
http://openweathermap.org/current#one
Get current weather for several cities within a rectangle zone
The getCurrentWeatherForSeveralCitiesWithinRectangle operation returns the data from cities within the defined rectangle.
<openweathermap.getCurrentWeatherForSeveralCitiesWithinRectangle> <bbox>{$ctx:bbox}</bbox> <lang>{$ctx:lang}</lang> <cluster>{$ctx:cluster}</cluster> <callback>{$ctx:callback}</callback> </openweathermap.getCurrentWeatherForSeveralCitiesWithinRectangle>
Properties
- bbox: Bounding box [lat of the top left point, lon of the top left point, lat of the bottom right point, lon of the bottom right point, map zoom].
- lang: language [ru, en ... ].
- cluster: Use server clustering of points. Possible values are [yes, no].
- callback: Javascript function Name.
Sample request
Following is a sample REST/JSON request that can be handled by the getCurrentWeatherForSeveralCitiesWithinRectangle operation.
{ "apiUrl":"http://api.openweathermap.org", "apiKey":"927d09bc49dbee6aac7f5cb1df707542", "apiVersion":"2.5", "bbox":"12,32,15,37,10", "cluster":"yes", "callback":"test" }
Related OpenWeatherMap documentation
http://openweathermap.org/current#one
Get current weather for several cities in cycle
The getCurrentWeatherForSeveralCitiesWithinCycle operation returns data from cities laid within definite circle .
<openweathermap.getCurrentWeatherForSeveralCitiesWithinCycle> <lat>{$ctx:lat}</lat> <lon>{$ctx:lon}</lon> <cnt>{$ctx:cnt}</cnt> <lang>{$ctx:lang}</lang> <cluster>{$ctx:cluster}</cluster> <callback>{$ctx:callback}</callback> </openweathermap.getCurrentWeatherForSeveralCitiesWithinCycle>
Properties
- lat: City geographic location, latitude.
- lon: City geographic location, longitude.
- cnt: Number of cities around the point that should be returned.
- lang: language [ru, en ... ].
- cluster: Use server clustering of points. Possible values are [yes, no].
- callback: Javascript function Name.
Sample request
Following is a sample REST/JSON request that can be handled by the getCurrentWeatherForSeveralCitiesWithinCycle operation.
{ "apiUrl":"http://api.openweathermap.org", "apiKey":"927d09bc49dbee6aac7f5cb1df707542", "apiVersion":"2.5", "lat":"35", "lon":"139", "cnt":"10", "lang":"en", "cluster":"yes", "callback":"test" }
Related OpenWeatherMap documentation
http://openweathermap.org/current#one
Get current weather for several city IDs
The getCurrentWeatherForSeveralCityIDs operation returns data from several city IDs.
<openweathermap.getCurrentWeatherForSeveralCityIDs> <cityIDs>{$ctx:cityIDs}</cityIDs> <units>{$ctx:units}</units> </openweathermap.getCurrentWeatherForSeveralCityIDs>
Properties
- cityIDs: Several city IDs
- units: Units metric, imperial. When you do not use units parameter, units is Standard by default
Sample request
Following is a sample REST/JSON request that can be handled by the getCurrentWeatherForSeveralCityIDs operation.
{ "apiUrl":"http://api.openweathermap.org", "apiKey":"927d09bc49dbee6aac7f5cb1df707542", "apiVersion":"2.5", "cityIDs":"524901,703448,2643743", "units":"metric" }
Related OpenWeatherMap documentation
http://openweathermap.org/current#one
Search accuracy
To set the accuracy level either use the 'accurate' or 'like' type parameter. 'accurate' returns exact match values. 'like' returns results by searching for that substring.
<openweathermap.search> <cityName>{$ctx:cityName}</cityName> <type>{$ctx:type}</type> <mode>{$ctx:mode}</mode> </openweathermap.search>
Properties
- cityName: The name of city
- type: Accuracy level either use the 'accurate' or 'like.
- mode: Possible values are xml and html. If mode parameter is empty the format is JSON by default.
Sample request
Following is a sample REST/JSON request that can be handled by the search operation.
{ "apiUrl":"http://api.openweathermap.org", "apiKey":"927d09bc49dbee6aac7f5cb1df707542", "apiVersion":"2.5", "cityName":"Washington", “type”:”like”, “mode”:”html” }
Related OpenWeatherMap documentation
http://openweathermap.org/current#one
Sample configuration
Following is a sample proxy service that illustrates how to connect to OpenWeatherMap with the init operation and use the getCurrentWeatherForOneLocByCityName operation. The sample request for this proxy can be found in the getCurrentWeatherForOneLocByCityName sample request.
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="openweathermap" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <property name="apiUrl" expression="json-eval($.apiUrl)"/> <property name="apiKey" expression="json-eval($.apiKey)"/> <property name="apiVersion" expression="json-eval($.apiVersion)"/> <property name="cityName" expression="json-eval($.cityName)"/> <property name="cityCountry" expression="json-eval($.cityCountry)"/> <openweathermap.init> <apiUrl>{$ctx:apiUrl}</apiUrl> <apiKey>{$ctx:apiKey}</apiKey> <apiVersion>{$ctx:apiVersion}</apiVersion> </openweathermap.init> <openweathermap.getCurrentWeatherForOneLocByCityName> <cityName>{$ctx:cityName}</cityName> <cityCountry>{$ctx:cityCountry}</cityCountry> </openweathermap.getCurrentWeatherForOneLocByCityName> <respond/> </inSequence> <outSequence/> <faultSequence/> </target> <description/> </proxy>