Customize a story using Python

Learn how to customize an existing story in ArcGIS StoryMaps using Python.

LA parks and trails story created with ArcGIS StoryMaps

The ArcGIS API for Python provides a set of tools and functionalities to interact with ArcGIS Online, ArcGIS Enterprise, and ArcGIS StoryMaps.

In this tutorial, you use the StoryMap object to update the title and summary of a story and share it publicly.

Prerequisites

Steps

1. Install the ArcGIS API for Python

If you have not done this, you will need to install the ArcGIS API for Python library. You can do this by running the following command in your Python environment:

Use dark colors for code blocksCopy
1
pip install arcgis

If you have Python 3.x.x installed, run the following command:

Use dark colors for code blocksCopy
1
pip3 install arcgis

2. Authenticate and connect to ArcGIS Online

To access and customize your ArcGIS StoryMaps, you need to authenticate and connect to your ArcGIS Online account. You can do this by creating an instance of the GIS class and providing your login credentials:

Use dark colors for code blocksCopy
1
2
3
4
from arcgis.gis import GIS

# Create a GIS object and authenticate
gis = GIS("https://www.arcgis.com", "username", "password")

3. Retrieve and modify a story

Once you are connected, you can retrieve a story by its ID or search for it using specific criteria. For example, to retrieve a story by its ID:

Use dark colors for code blocksCopy
1
2
3
# Retrieve a story by its ID
storymap_id = "your_storymap_id"
storymap = gis.content.get(storymap_id)

4. Customize the story

You can customize various aspects of the story, such as its title, summary, cover image, layout, and content. Here is an example of updating the title and summary:

Use dark colors for code blocksCopy
1
2
3
4
5
# Update the title and summary of the story
new_title = "New Title"
new_summary = "This is a customized story created using Python."

storymap.update(item_properties={'title': new_title, 'snippet': new_summary})

You can explore the item_properties dictionary to see other available properties you can modify.

5. Save and publish the changes

After making the desired modifications, you need to save and publish the changes to apply them to the story:

Use dark colors for code blocksCopy
1
2
3
# Save and publish the changes
storymap.save()
storymap.share(everyone=True)  # Optionally, make the story public

You can adjust the sharing settings according to your requirements.

These are the basic instructions to get started with customizing ArcGIS StoryMaps using ArcGIS API for Python. Please refer to the Python API documentation for more detailed information and examples to help you further explore and utilize its capabilities.

Tutorials

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.