Expose and Consume RESTful Web Services
Ignition REST API: Build Web Services for Your SCADA Data
Build powerful REST APIs to expose your Ignition SCADA data to external systems. Use the WebDev module to create custom GET and POST endpoints with Python scripting, enabling seamless integration with ERP, MES, mobile apps, and custom dashboards.
Overview
The Ignition REST API enables bidirectional communication between your SCADA system and any HTTP-capable application. Using the WebDev module, you can expose tag values, historical data, and alarm states through standard RESTful endpoints that any modern system can consume.
Combined with Python scripting and Ignition's system.net.httpClient function, you can also consume external REST APIs to pull data from ERP systems, weather services, or any third-party platform directly into your SCADA environment.
Key Benefits
- Expose SCADA data via standard HTTP endpoints
- Full JSON and XML request/response support
- Python scripting for custom business logic
- Secure endpoints with OAuth and token-based authentication
- Bidirectional data exchange with enterprise systems
REST API Architecture
The WebDev module sits on the Ignition Gateway, exposing RESTful endpoints that external systems consume over HTTP/HTTPS. Incoming requests are routed through Python handler scripts that interact with the tag system and database.
┌─────────────────────────────────────┐
│ External Systems │
│ ┌─────┐ ┌─────┐ ┌────────────┐ │
│ │ ERP │ │ MES │ │ Mobile App │ │
│ └──┬──┘ └──┬──┘ └─────┬──────┘ │
│ │ │ │ │
└─────┼────────┼────────────┼─────────┘
│ │ │
▼ ▼ ▼
┌─────────────────────────────────────┐
│ REST API (WebDev Module) │
│ GET /api/tags POST /api/write │
│ GET /api/history POST /api/cmd │
│ ┌──────────────────────┐ │
│ │ Python Handlers │ │
│ │ Authentication │ │
│ │ CORS / Rate Limit │ │
│ └──────────┬───────────┘ │
└────────────────┼────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Ignition Gateway │
│ ┌──────────┐ ┌─────────────────┐ │
│ │ Tag │ │ Database │ │
│ │ Provider │ │ Connections │ │
│ └──────────┘ └─────────────────┘ │
└─────────────────────────────────────┘
Configuration Steps
Step 1: Install the WebDev Module
Download and install the WebDev module from the Ignition Gateway. Navigate to Config > Modules, upload the .modl file, and restart the gateway. The WebDev module enables you to create custom HTTP endpoints directly on your Ignition Gateway.
# Verify the WebDev module is installed and running
# Navigate to: https://your-gateway:8088/system/webdev/
#
# The module adds a new "WebDev" section in the Ignition Designer
# where you can create and manage your REST API resources.
#
# Default base URL for your endpoints:
# https://your-gateway:8088/system/webdev/your-project/Step 2: Create a GET Endpoint to Read Tags
Create a new WebDev resource in the Ignition Designer and implement a doGet handler. This Python script reads tag values and returns them as a JSON response, making your SCADA data accessible via a simple HTTP GET request.
# WebDev Resource: doGet handler
# Endpoint: GET /system/webdev/my-project/api/tags
#
def doGet(request, session):
"""Read tag values and return as JSON."""
import json
# Read multiple tags at once
tag_paths = [
"[default]Plant/Temperature",
"[default]Plant/Pressure",
"[default]Plant/FlowRate",
"[default]Plant/Status"
]
values = system.tag.readBlocking(tag_paths)
# Build response object
response_data = {}
for path, qv in zip(tag_paths, values):
tag_name = path.split("/")[-1]
response_data[tag_name] = {
"value": qv.value,
"quality": str(qv.quality),
"timestamp": str(qv.timestamp)
}
# Return JSON response
return {
"json": response_data,
"contentType": "application/json"
}Step 3: Create a POST Endpoint to Write Tags
Implement a doPost handler to receive data from external systems and write values to Ignition tags. The handler parses the incoming JSON payload, validates the data, and performs tag writes with proper error handling.
# WebDev Resource: doPost handler
# Endpoint: POST /system/webdev/my-project/api/write
#
def doPost(request, session):
"""Write tag values from an incoming JSON payload."""
import json
# Parse the JSON body
body = request["data"]
payload = json.loads(body)
# Validate required fields
if "writes" not in payload:
return {
"json": {"error": "Missing 'writes' field"},
"code": 400
}
tag_paths = []
tag_values = []
for write in payload["writes"]:
tag_paths.append(write["path"])
tag_values.append(write["value"])
# Execute tag writes
results = system.tag.writeBlocking(tag_paths, tag_values)
# Build response with write results
write_results = []
for path, result in zip(tag_paths, results):
write_results.append({
"path": path,
"success": result.isGood()
})
return {
"json": {
"status": "completed",
"results": write_results
},
"contentType": "application/json"
}Step 4: Add Authentication and CORS
Secure your Ignition REST API by adding token-based authentication and CORS headers. Validate API keys or Bearer tokens in a shared utility script, and configure CORS to allow requests only from trusted origins.
# Shared script: project.auth.validateRequest
#
def validateRequest(request):
"""Validate API key from request headers."""
auth_header = request.get("headers", {}).get("Authorization", "")
if not auth_header.startswith("Bearer "):
return False, {
"json": {"error": "Missing or invalid Authorization header"},
"code": 401
}
token = auth_header[7:] # Remove "Bearer " prefix
valid_tokens = system.tag.readBlocking(
["[default]Config/API/ValidTokens"]
)[0].value
if token not in valid_tokens.split(","):
return False, {
"json": {"error": "Invalid API token"},
"code": 403
}
return True, None
# Updated doGet with auth and CORS
def doGet(request, session):
"""Secured GET endpoint with CORS support."""
import json
# CORS headers for cross-origin requests
cors_headers = {
"Access-Control-Allow-Origin": "https://your-app.com",
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Authorization, Content-Type"
}
# Handle preflight OPTIONS request
if request.get("method") == "OPTIONS":
return {"code": 204, "headers": cors_headers}
# Validate authentication
is_valid, error_response = project.auth.validateRequest(request)
if not is_valid:
error_response["headers"] = cors_headers
return error_response
# Proceed with tag reading
tag_paths = ["[default]Plant/Temperature"]
values = system.tag.readBlocking(tag_paths)
return {
"json": {"Temperature": values[0].value},
"headers": cors_headers,
"contentType": "application/json"
}Key Features
WebDev Module Endpoints
Create fully customizable REST endpoints directly on the Ignition Gateway. Support for GET, POST, PUT, DELETE, and OPTIONS methods with URL parameter parsing and request body handling.
JSON & XML Support
Parse and generate JSON and XML payloads natively. Serialize tag values, historical data, and alarm events into structured formats that any client application can consume.
Python Scripting Engine
Leverage Jython scripting to implement custom business logic, data transformations, and complex workflows within your REST API handlers. Access the full Ignition scripting API including tags, databases, and alarms.
OAuth & Token Authentication
Secure your Ignition REST API with Bearer token validation, API key management, and OAuth 2.0 integration. Implement role-based access control to restrict endpoint access by user or application.
Use Cases
Mobile App Integration
Expose real-time SCADA data to mobile applications through a secure Ignition REST API. Field technicians can view live tag values, acknowledge alarms, and update setpoints from smartphones and tablets without a full Perspective session.
ERP & MES Data Exchange
Enable bidirectional data flow between Ignition and enterprise resource planning systems. Push production counts, quality metrics, and equipment status to SAP or Oracle, and pull work orders and recipes back into the SCADA layer via REST API calls.
Custom Dashboards & Reporting
Feed live and historical SCADA data into custom web dashboards, business intelligence tools, or reporting platforms. Use the Ignition REST API to supply Grafana, Power BI, or bespoke React applications with production data in real time.
Technologies
WebDev Module
Ignition module that enables creating custom REST API endpoints with Python handlers for GET, POST, PUT, and DELETE operations on the Gateway.
Python Scripting
Jython-based scripting engine for implementing endpoint logic, data transformations, validation, and integration with Ignition's tag, alarm, and database systems.
JSON
Lightweight data-interchange format used for request and response payloads. Natively supported in Ignition's scripting environment via the json module.
system.net.httpClient
Ignition scripting function for consuming external REST APIs. Supports GET, POST, PUT, DELETE methods with custom headers, timeouts, and SSL/TLS configuration.
system.tag API
Core Ignition API for reading and writing tag values, browsing the tag tree, and accessing tag history. Used within REST handlers to bridge HTTP requests to the tag system.
Frequently Asked Questions
Find answers to common questions about this integration.
Ready to Get Started?
Contact our team of experts to discuss your integration needs and get a customized solution.