# Webdev Module - Expose tag data example

**URL:** <https://forum.inductiveautomation.com/t/webdev-module-expose-tag-data-example/17948>\
**Category:** Ignition\
**Created:** [May 7, 2018, 8:22pm UTC](https://forum.inductiveautomation.com/t/webdev-module-expose-tag-data-example/17948 "2018-05-07T20:22:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oscar.salcedo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/oscar.salcedo/32/11019_2.png) [@oscar.salcedo](https://forum.inductiveautomation.com/u/oscar.salcedo)\
**Post date:** [May 7, 2018, 8:22pm UTC](https://forum.inductiveautomation.com/t/webdev-module-expose-tag-data-example/17948/1 "2018-05-07T20:22:52Z")

</div>

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 🙂, since it can traverse through the tag path provided and has the potential to do some damage in large systems…

```auto
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:
    break
tagPathParts.append(partVal)
tagPath = 'Enterprise/' + '/'.join(tagPathParts)

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

```

#Endpoint  
[http://GatewayHost/main/system/webdev/api/core/get\_tags](http://GatewayHost/main/system/webdev/api/core/get_tags)

#Example Requests  
[http://GatewayHost/main/system/webdev/api/core/get\_tags?site=New%20Albany&area=Assembly&line=M98](http://GatewayHost/main/system/webdev/api/core/get_tags?site=New%20Albany&area=Assembly&line=M98)  
[http://GatewayHost/main/system/webdev/api/core/get\_tags?site=New%20Albany&area=Assembly&line=M98&cell=Assembly\_Array](http://GatewayHost/main/system/webdev/api/core/get_tags?site=New%20Albany&area=Assembly&line=M98&cell=Assembly_Array)  
[http://GatewayHost/main/system/webdev/api/core/get\_tags?site=New%20Albany&area=Assembly&line=M98&cell=Assembly\_Array&tag=Accumulated%20Parts](http://GatewayHost/main/system/webdev/api/core/get_tags?site=New%20Albany&area=Assembly&line=M98&cell=Assembly_Array&tag=Accumulated%20Parts)

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”  
}  
}
