Access external REST API

Cumulocity latest version

I want to be able to access data from an external REST API, to pull in data from that platform and use it together with existing devices in C8Y.

Can’t seem to find the right documentation/references on how this could be done.

(I am very new to the system so please bare with me).

Hi,

depending on what kind of and how much data you’d need you can either call external API within a custom widget (just in the UI) or implement a microservice which access the external API.

See here: Getting started - Cumulocity IoT Guides

Hi @bartwybouw ,

Depending on your requirements, there are different ways on how this could be implemented.

In case you just want to display additional data for a device that is provided by an external REST API somewhere in the UI, you could extend the default UI and perform requests to your API via the UI. To get started with UI development, you might want to look into: https://cumulocity.com/docs/web/overview/ If you e.g. want to display the current weather at the device’s location, you could make a call to some third party weather API and display it.

Performing the requests via the UI has the drawback that no history is kept for the data you’ve been retrieving. So for the weather sample, you would would be able to see what the current weather is and maybe even a forecast (if the API provides that), but you would not store that data, so the information is lost and has to retrieved every time from that API when you want to view it.

If you want to keep a history of the data and store it somewhere in Cumulocity, you want to write a small backend for that purpose.
You have two options to do so:

  1. Write a microservice (Introduction - Cumulocity documentation)
  2. Write an Apama EPL app (EPL Apps - Cumulocity documentation)
  3. Create an external application that interacts with the Cumulocity REST API to feed in the additional data. (Cumulocity - OpenAPI Specifications)

For the microservice option, you could use the Java Microservice SDK offered by Cumulocity, or you could write your own microservice in your preferred programming language.

Regards,
Tristan

2 Likes

Hi Christoph,

thanks for your reply. It’s actually data that only gets update about once every hours, so nothing too busy.
Can you point me to an example on how to do that with a widget?
(I’m not sure my knowledge is technical enough to develop a microservice).

Thanks!

Tristan’s reply was actually much more detailed and already pointed you at the right guide: Tutorials - Cumulocity IoT documentation. I’m not a UI person myself and can’t point to to a nice example, but there are many repos hosted in Github that should provide some guidance.

This weather widget for example uses an external API: GitHub - SoftwareAG/cumulocity-weather-forecast-widget: Displays a 5-day weather forecast using weather data provided by the OpenWeatherAPI. Developed by Global Presales.

Tristan gave already a pretty good answer. I wanted to add my guide Data integration options with Cumulocity IoT which might give you some starting point understanding the basic concepts & options you have to integrate data.

Especially the Service Integration seems to be the one you are looking for.

If you are not the technical guy and don’t want to develop anything but do this on configuration level you might check out one of the 3rd party tools mentioned here

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.