Esri/arcgis-python-api

Identify a StoryMap's Theme

Closed this issue · 7 comments

I am interested in a simple way of determining which StoryMap Theme a StoryMap is using. My overall goal is to generate statistics across our organization about which of the built-in and custom Themes are most commonly used.

One can extract a story's theme information manually by locating the node with the type of "story-theme" among all of the story's nodes.

It would be helpful to have the theme information surfaced directly. For example, perhaps "theme" could be a returned property, or added as type option for get() to get directly to its node.

@knoopum Great suggestion I will work on putting this in. For now the workaround about looking at the node is the best way but we can add a property or make it so the method returns a theme if no parameters are given :)

I'll note a complication I ran into is that StoryMap Collections, which can also reference Themes, are not currently accessible via the API. Passing an item ID for a StoryMap Collection to arcgis.apps.storymap.StoryMap() results in a 404.

For Collections, it looks like I will have to harvest the Theme info from the item's JSON for now?

@knoopum Good news for collections! Support will be added at 2.3.0 (coming out next week) so you will be able to access them soon. However the theme property you are suggesting was not added so it will be in Storymap, Collections, and Briefings for 2.3.1

I would refer to the json for now. I will make a custom method and can post it here soon as well to facilitate this.

@nanaeaubry that is great! I'll scrape the JSON in the meantime, and look forward to the updates

Here is a quick method that can be used to get the theme

def get_theme(story):
    """
    Get the theme of the story, briefing, or collection.
    """

    for node, node_info in story._properties["resources"].items():
        for key, val in node_info.items():
            if key == "type" and val == "story-theme":
                return story._properties["resources"][node]["data"]["themeId"]

This will either return the name or the itemid of the theme used

@nanaeaubry Thank you! that confirms the logic I ended up using

This will be a method in the next release of the API