For the complete documentation index, see llms.txt. This page is also available as Markdown.

RESTful API

Using weather REST API ..

Weather API

CDE weather dashboard

Follow the steps outlined below to activate CDE and test the API call with Postman.

Postman

To activate the Community Dashboard Editor (CDE) plugin, you will need to change the configuration of several .xml files in the Pentaho solutions folder as described below. Verify that you have the appropriate permissions to read, write, and execute commands in the specified directories in the instructions.

  1. Ensure the Pentaho Server is stopped.

  1. Uncomment the following lines:

  1. Locate the following two commented blocks in this file and remove the comment tags from these blocks.

  1. Save.

  1. Uncomment the following lines:

  1. Locate the block at end of the file, 'Defining the new-toolbar-button' and remove the comments tags from this block

  1. Locate the block at end of the file, 'Defining the new-toolbar-button' and remove the comments tags from this block.

  2. Save.

  1. Save your changes.

  2. Restart the Pentaho Server.


Community Dashboard Editor (CDE)

To verify CDE is activated, do the following.

  1. Log on to the Pentaho User Console.

  2. From the Home page, click the Create New button.

  3. From the menu that displays, select the New CDE Dashboard option. You can now begin creating your first CDE dashboard.

CDE Dashboard
  1. Sign up for a free Openweather account.

  1. Once registered, generate an API key.

Generate a key
  1. Read the API documentation for deployment - Geocoding

Link to Openweathermap API
Parameters
Description

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

Postman is an API platform for building and using APIs.

  1. Sign up - for free - & download Postman.

You can also install Postman as a VS Extension or from Snap.

  1. Once logged into your account you can test your API weather call and test the output of various parameters.

Test
Query Params
Value

https://api.openweathermap.org/data/2.5/weather?

q=

{city name}

london

{state code}

England

{country code}

GB

appid

{API key}

Optional Params

  1. Edit the query to set the mode & units.

Params
Description

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

Resources

REST API documentation API information for building custom solutions of Pentaho products.

The CDE is a Pentaho service.

x

x

weather API

Weather API

  1. Start Pentaho Server.

  1. Open the following transformation in Pentaho Data Integration.

~/Workshop--Data-Integration/Labs/Module 7 - Workflows/API/tr_weather_cda.ktr

  1. Browse through the following steps.

As you already know, Kettle variables can be used in Jobs and Transformations wherever you see a dollar sign. There is one more way to use variables - getting their values as fields of your stream. For this, you have to use the Get Variables step.

With the Get Variables step, you can get the value for one or more variables. The kind of variable can be any of the Kettle variables types you just learned the variables defined in the kettle.properties file, internal variables, for example, ${user.dir}, named parameters, or other Kettle variables.

  1. Double-click on the step to view settings.

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

Default Named parameters

The REST Client transformation step enables you to consume RESTfull services.

For a simple http GET request you can also use: http client step.

  1. Double-click on the step to view settings.

HTTP Client step

Based on the openweathermap API documentation:

• the URL calls the service to return the weather data based on:

${city}=London

${country}=GB

${units}=metric

${mode}=xml

• 'response' is return to the 'results' data stream field.

• the fields are 'mapped' in the fileds tab.

map parameter fields to URL

This step provides the ability to read data from any type of XML file using XPath specifications.

For further details: Get data from XML

  1. Double-click on the step to view settings.

Get data from XML - defined in a field

The response from the API call - results - is the data source.

  1. Click on the 'Content' tab.

Determine XPath

To determine the XPath, you will need to copy and paste a snippet of the API call.

The root is: /current

  1. Click on Fields tab.

Set the XPath / data Type to Nodes and attributes to retrieve the field values

The Row Normaliser step converts the columns of an input stream into rows. You can use this step to normalize repeating groups of columns.

  1. Double-click on the step to view settings.

Row Normaliser

The Select values step can perform all the following actions on fields in the PDI data stream:

• Select values

• Remove values

• Rename values

• Change data types

• Configure length and precision of values

x

x

x

Community Data Access (CDA) allows you to gather and combine data from several data sources into a single structure, which you can then use in dashboards. Driven by the need to unify access to the Pentaho data layer, CDA was developed to create an abstraction layer between a CTools dashboard and the physical connections to different databases.

CDA has three main objectives:

  • Combine data from several sources

  • Ensure security while accessing the data (avoiding, for instance, SQL injection problems)

  • Ease data exports

  1. View the following CDA file.

~/Workshop--Data-Integration/

x

x

  1. Define a connection to the 'Pentaho' Repository.

Pentaho Repository
  1. Create a folder: Public / weather

x

x

x

x

Last updated

Was this helpful?