Webdev Module - Expose tag data example

I have seen this topic come up a few times recently and I thought I’d share our solution to expose tag data to external systems via the Webdev module.

The example is kind of raw and very specific for our UDT structures; it should be used with caution :slight_smile:, since it can traverse through the tag path provided and has the potential to do some damage in large systems…

def tagsToDict(tagsPath):
# TODO: Batch tag reads with system.tag.readAll()
# https://support.inductiveautomation.com/usermanuals/ignition/index.html?system_tag_read.htm
tags = system.tag.browseTags(parentPath=tagsPath)

# Leaf node
if not tags:
    tag = system.tag.read(tagsPath)
    return {
        'value': tag.value,
        'quality': tag.quality.toString(),
        'timestamp': tag.timestamp,

tagDict = {}
for tag in tags:
    tagDict[tag.name] = tagsToDict(tag.fullPath)

return tagDict

tagPathParts = []
pathParts = ['site', 'area', 'line', 'cell', 'tag']
params = request['params']
for part in pathParts:
partVal = params.get(part)
if not partVal:
tagPath = 'Enterprise/' + '/'.join(tagPathParts)

response = {
'params': dict(zip(pathParts, tagPathParts)),
'data': tagsToDict(tagPath),
return { 'json': system.util.jsonEncode(response) }


#Example Requests

Response (JSON)
“data”: {
“Assembly_Array”: {
“Accumulated Pins Used”: {
“value”: 134389334,
“quality”: “Good”,
“timestamp”: “Wed Oct 18 07:14:57 EDT 2017”

“params”: {
“area”: “Assembly”,
“site”: “New Albany”,
“line”: “M98”

1 Like