RESTful API
Using weather REST API ..
Use Case - Weather API
Accurate weather information and forecasts are essential elements in critical decision-making scenarios. Both enterprises and individual consumers rely on current and future weather patterns to run their daily operations and manage risks successfully.
As such, the increased demand for accurate weather information has pushed the developer community to invest in building reliable weather apps.
So in this workshop we're going to:
use a weather API.
pull the data into PDI.
display dataset in a CDE dashboard - Pentaho Server service.

The following section is for Reference only.
The CDE has been activated.
You may require to create an Openweathermap account.
Follow the steps outlined below to activate CDE and test the API call with Postman.

Ensure the Pentaho Server is stopped.
Uncomment the following lines:
/opt/pentaho/server/pentaho-server/pentaho-solutions/system/pentaho-cdf-dd/plugin.xml
Locate the following two commented blocks in this file and remove the comment tags from these blocks.
Save.
Uncomment the following lines:
/opt/pentaho/server/pentaho-server/pentaho-solutions/system/pentaho-cdf-dd/settings.xml
Locate the block at end of the file, 'Defining the new-toolbar-button' and remove the comments tags from this block
Locate the block at end of the file, 'Defining the new-toolbar-button' and remove the comments tags from this block.
Save.
Save your changes.
Restart the Pentaho Server.
Community Dashboard Editor (CDE)
To verify CDE is activated, do the following.
Log on to the Pentaho User Console.
From the Home page, click the Create New button.
From the menu that displays, select the New CDE Dashboard option. You can now begin creating your first CDE dashboard.

Sign up for a free Openweather account.
Once registered, generate an API key.

Read the API documentation for deployment - Geocoding
q
required
City name, state code (only for the US) and country code divided by comma. Please use ISO 3166 country codes.
appid
required
Your unique API key (you can always find it on your account page under the "API key" tab)
limit
optional
Number of the locations in the API response (up to 5 results can be returned in the API response)
Example
Sign up - for free - & download Postman.
Once logged into your account you can test your API weather call and test the output of various parameters.

The new 'One Call' API requires the location latitude & logitude.
This method usues a deprecated Geocoding API to resolve city, state, country - ISO 3166.
https://api.openweathermap.org/data/2.5/weather?
q=
{city name}
london
{state code}
England
{country code}
GB
appid
{API key}

Optional Params
Edit the query to set the mode & units.
mode
Possible values are xml and html. If you don't use the mode parameter format is JSON by default.
units
Units of measurement. standard, metric and imperial units are available. If you do not use the units parameter, standard units will be applied by default.
lang
You can use this parameter to get the output in your language.
x
CDF API Pentaho Data Integration and Analytics CDF API documentation.
Pentaho Data Integration and Analytics Platform JavaScript API.
x
x

Weather API
Start Pentaho Pro Suite.
Open the following transformation in Pentaho Data Integration.
~/Workshop--Data-Integration/Labs/Module 7 - Workflows/API/tr_weather_cda.ktr
Browse through the following steps.
Double-click on the step to view settings.

The variables & default values are pulled from 'Named Parameters' set in the Transformation properties.

Double-click on the step to view settings.


Double-click on the step to view settings.

Click on the 'Content' tab.


Click on Fields tab.

Double-click on the step to view settings.

x
x
x
View the following CDA file.
~/Workshop--Data-Integration/
x
x
Define a connection to the 'Pentaho' Repository.

Create a folder: Public / weather
x
x
x
x
Last updated
Was this helpful?

