# Get the Historical Tag Path from the Tag Path

**URL:** <https://forum.inductiveautomation.com/t/get-the-historical-tag-path-from-the-tag-path/61981>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [July 16, 2022, 5:27pm UTC](https://forum.inductiveautomation.com/t/get-the-historical-tag-path-from-the-tag-path/61981 "2022-07-16T17:27:45Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 18, 2022, 6:09pm UTC](https://forum.inductiveautomation.com/t/get-the-historical-tag-path-from-the-tag-path/61981/6 "2022-07-18T18:09:01Z")

</div>

So, the driver is actually part of the full tag path. It is possible if you are using remote tag providers to use a gateway message handler in conjunction with this function to get what you’re looking for.

If you put this function in a shared script on the same gateway as the tag provider, then it should return your historical tag path.

Inspired heavily from the script provided by @paul-griffith

```python
def getHistoricalTagPath(path):
    from com.inductiveautomation.ignition.common import QualifiedPath, WellKnownPathTypes,QualifiedPathUtils
    from com.inductiveautomation.ignition.common.tags.paths.parser import TagPathParser

    qPath = QualifiedPathUtils.fromTagPathNew(TagPathParser.parseSafe('default',path))
    histProv, gateway = system.tag.readBlocking([path + '.historyProvider','[System]Gateway/SystemName'])
    driver = ':'.join([gateway.value,qPath.getPathComponent('prov')])
    return QualifiedPath.Builder().set(WellKnownPathTypes.HistoryProvider,histProv.value).setDriver(driver).setTag(qPath.getPathComponent('tag')).build().toString()

```

So using the following assumptions:

1. The system name of the gateway this function is run on is `controller`
2. The historical provider of the tag is set to `DB`
3. You provide the path `'[default]simulater/turbine 3'` or `'simulater/turbine 3'`

Then this function will return `histprov:DB:/drv:controller:default:/tag:simulater/turbine 3`

You could also just hard code the gateway in if it isn’t going to change often.

I chose to use `system.tag.readBlocking()` here because `system.tag.getConfiguration()` only returns non-default properties, since a historical provider is not provided by default it should always be returned, but better safe than sorry. Also, I needed to call the function anyway to get the gateway name, so just as easy to get it from there.

You may want to consider either verifying that history is enabled for the provided path, or coalescing to a default if a ‘historical provider’ is not provided.

If you take out the `toString()` and instead return just a QualifiedPath then you could use this function to do a lot of things, for instance checking for incorrect configurations.

```auto
print [tag['fullPath'] for tag in system.tag.browse('path/to/folder',{'tagType':'Atomic Tag'}).getResults() if getHistoricalTagPath(tag['fullPath']).getPathComponent('prov') in ('null','SomeOtherIncorrectProvider')]

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/get-the-historical-tag-path-from-the-tag-path/61981)._
