REST data interface

Introduction

In this topic you will learn about the REST-based approach of PLCnext Technology which is utilized to exchange data via HTTP with the PLCnext Control's firmware and with data in the Global Data Space (GDS).

REST, or REpresentational State Transfer, is a software architecture style consisting of guidelines and best practices for creating scalable web services.

Key features of the PLCnext REST data interface are:

  • Access data via GDS ports or PLC variables
    (Note: Only GDS ports and variables that are tagged with the HMI attribute can be accessed via REST API)
  • Authorization on different user levels, based on the PLCnext Engineer HMI user management
  • Encrypted data transmission via HTTPS

This REST data interface is versioned, and each version is kept stable and will be maintained.  As a general interface for data exchange, it is also available for use with other REST clients.

Note: Phoenix Contact reserves the right to make changes and additions in further versions that might lead to incompatibilities. Therefore it is highly recommended to call this REST data interface out of your application explicitly with the version used during development, not with the latest key.

Concept

The REST data interface is provided by the PLCnext HMI component for use by a PLCnext Engineer HMI client, which is usually a browser-based application running on the embedded nginx webserver on any PLCnext Control.

This schematic drawing shows where the REST data interface sits in the context of the PLCnext Runtime System:

How to

It's not that difficult to make use of the REST data interface - but there's a bunch of detailed reference information coming up. Let's guide you to the different topics, so you won't get lost before succeeding.

  1. First of all, you will need a short but completed PLCnext Engineer project, because in order to use the REST data interface the PLCnext HMI component has to be started up out of a  PLCnext Engineer project. The PLCnext Engineer project needs to contain a minimum of one HMI page (may be empty at first) in order to initialize the PLCnext HMI component. In the PLCnext Engineer project all GDS ports or PLC variables to be accessed with the REST data interface must be approved with theHMI flag.
    Note: If you're not familiar yet with PLCnext Engineer and its HMI editor, read the PLCnext Engineer HMI topic first.
  2. Then you need to get authorized access to the GDS ports and PLC variables through the REST data interface. Read the authentication topic to see how that is done.
  3. Once the sesame is open, you are free to read or write variables, set up variables in groups, retrieve session reports, and doing that by sending all kinds of requests.

 

 


• Published/reviewed: 2024-10-30   ☀  Revision 074 •