Let's Take a REST...API and Integrate a Wide Variety of Data

6 min read

Feb 9, 2023 2:00:00 PM

So, no, we're not actually taking a rest - we're looking at what REST the acronym means from a practical perspective. But perhaps after reading this, if you're looking to connect to a RESTful API, you can give your mind a rest knowing you have a path forward.

I know the first time I ever heard the term, I had no idea what it meant or how to approach it. Maybe you've been told a certain data source has a REST API for accessing it, but you're not sure where to get started leveraging that API with your control system.

This post will provide a practical explanation of what REST is, how it can be useful to you and how you can take advantage of data provided by RESTful APIs or web services in your operations.

What is a RESTful API?

REST or REpresentational State Transfer is a type of protocol, of sorts, that software can use to communicate with other software generally over the internet. And an API is an Application Programming Interface. Like any protocol, RESTful APIs or web services define a set of rules for sending and receiving data and an accepted format of what those sends and receives should be.

Diagram_REST_API_Clients_Servers
REST is "stateless" such that all RESTful clients and servers operate independently and the calls sent between the two are independent of one another. There's no handshaking - it's an asynchronous sort of process where client requests are processed by the server regardless of any prior requests (there's no record or consideration given of prior client requests). This makes REST communications lightweight and fast.

RESTful APIs tend to be used as a method of information exchange due to the scalability, flexibility and platform-independence. Since it's lightweight and there is no retention of previous client requests by the REST server, there is much lower load on the server and bottlenecks are reduced, allowing such APIs to scale well regardless of how many REST clients may need to access the REST server now or in the future. And since any programming platform can consume REST, you're not tied to any particular platform.

REST or RESTful APIs, specifically, are a way many organizations provide external (or even internal) access to a wide variety of useful information such as weather data (current, forecasted, historical, etc), energy pricing data (current, historical, etc) and more. Data that a modern HMI or SCADA can use towards a more comprehensive view of operations.

For instance, if your operations rely on solar power and you know a storm is coming that will decrease the output of your solar power plant, you and your systems can make decisions on that information. Or, if the cost of the electricity your plant is using is going to spike and cause your output to be less profitable for some amount of time, you might choose downtime over production because it's more profitable. Or, if the cost of the energy it requires to pump oil out of the ground costs more than the amount that same oil will be worth, you might choose downtime over production for the same reason. And many web-enabled and cloud-systems utilize REST as a standard-based method of integration with other systems.

Using a combination of HTTP (Hyper Text Transfer Protocol i.e. what the internet uses) methods, REST clients can tell the REST server/service/API what they want via the following:

  • GET requests tell the REST API specific data that the client wants returned (such as current weather for a specific location)
  • POST requests create new data or resources on the REST server/API
  • PUT requests are used to update existing data or resources
  • DELETE requests do what you would expect - they delete specified data or resources.

Security is another consideration with RESTful APIs - there are a number of different options for authentication that a REST API may or may not require (it might support one or more or it might not require authentication at all). Common options are:

  • Basic username/password authentication (for instance, this might be Basic HTML or use NTML, which is a Microsoft user/password based authentication protocol)
  • Token-based authentication (JWT, for instance, is JSON Web Token authentication)
  • Use of authorized API keys that are passed as part of every request by the client
  • OAuth authentication which is a combination of basic and token-based for higher protection

And, generally, REST APIs will support a message framework that is either JSON (JavaScript Object Notation) or XML (eXtensible Markup Language) based (sometimes they might support both based on what the REST client requests). That's essentially just a different format for representing the same data in plain text.

How to Integrate REST Web Services with Your Control System

But you're probably saying "That sounds great but I don't know how to consume REST data in my control system." Fortunately, when an organization decides to provide a REST API for accessing their information, they are typically well documented, make it relatively straightforward to implement the necessary REST API calls in a REST client.

OPC-Router_NewInfoGraphic-400w-380h

To that end, there is actually an off-the-shelf solution called OPC Router that makes it easy to integrate with REST web services (and other types of web services, for that matter) and then connect those web services to a wide variety of other applications, including but not limited to OPC UA clients and servers, OPC DA servers, SAP and other ERP systems, a variety of databases and more, all using an intuitive visual drag-and-drop workflow configuration.

As long as your control system supports one of the other OPC Router interfaces such as OPC, you'll be able to send/receive data with virtually any REST web service.

The following tutorial video on RESTful Web Services integration with OPC Router steps through actually setting up a connection to a RESTful API (Open Weather Map, specifically, but the same principles apply to any REST API).


It's easy to get started - if you'd like to follow along with the tutorial, you can download a free trial of OPC Router here and OpenWeatherMap offers free accounts that are useful for testing. And if you have a specific REST API that you're still not quite sure how to implement, reach out our team to discuss your options.

Integrate REST Data with OPC Router

Kevin Rutherford
Written by Kevin Rutherford

Software Toolbox Technical Blog

We're engineers like you, so this blog focuses on "How to" appnotes, videos, tech team tips, product update announcements, user case studies, and other technical updates.  Subscribe to updates below. Your feedback and questions on posts are always welcomed - just use the area at the bottom of any post.

Subscribe to our Blog

Recent Posts

Posts by Topic

See all