# How should I browse tags using the java API? Bugs?

**URL:** <https://forum.inductiveautomation.com/t/how-should-i-browse-tags-using-the-java-api-bugs/72029>\
**Category:** Module Development\
**Created:** [April 4, 2023, 4:00pm UTC](https://forum.inductiveautomation.com/t/how-should-i-browse-tags-using-the-java-api-bugs/72029 "2023-04-04T16:00:05Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Andrew\_Cunningham](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@Andrew\_Cunningham](https://forum.inductiveautomation.com/u/Andrew_Cunningham)\
**Post date:** [April 6, 2023, 8:58pm UTC](https://forum.inductiveautomation.com/t/how-should-i-browse-tags-using-the-java-api-bugs/72029/7 "2023-04-06T20:58:10Z")

</div>

Ok. I can say that this path (using `child.getName`) does work; if anyone else would find the code helpful, my version automatically recurses into (only) folders:

```kotlin
fun GatewayTagManager.streamTags(
    visit: (TagProvider) -> ((TagPath, TagConfigurationModel) -> Boolean)?
) {
    fun browseNode(visit: (TagPath, TagConfigurationModel)->Boolean, fullPath: TagPath, tagConfig: TagConfigurationModel) {
        if (visit(fullPath, tagConfig)) when (tagConfig.type) {
                TagObjectType.Folder -> {
                    for (child in tagConfig.children) {
                        browseNode(visit, fullPath.getChildPath(child.name), child)
                    }
                }
                else -> return
            }
        }
    }
    runBlocking {
        for (provider in tagProviders) {
            val root = TagPathParser.parse("[${provider.name}]") // Though one might use some subdir in some cases...
            val visitor = visit(provider)
                ?: continue
            val firstGenerations = provider.getTagConfigsAsync(listOf(root), true, false).get(30, TimeUnit.SECONDS)
            for (firstGeneration in firstGenerations) {
                when (firstGeneration.type) {
                    TagObjectType.Provider -> for (secondGeneration in firstGeneration.children) {
                        browseNode(visitor, root.getChildPath(secondGeneration.name), secondGeneration)
                    }
                    else -> browseNode(visitor, root.getChildPath(firstGeneration.name), firstGeneration)
                }
            }
        }
    }
}

```

---

_[View the full topic](https://forum.inductiveautomation.com/t/how-should-i-browse-tags-using-the-java-api-bugs/72029)._
