Skip To Content ArcGIS for Developers Sign In Dashboard


You will learn: how to use the ArcGIS API for Python to programmatically change the sharing settings for your layers.

You can publicly share layers, maps, and other items saved in your ArcGIS for Developers account. Until actively shared, items are not visible to others and do not appear in search results. Public items are accessible to everyone.

Developers should keep in mind that an item's sharing settings will impact any apps consuming that item. For example, if you have an app that's using a web map, and the web map is later set to 'private', the app will not display that map. In this quick lab, you'll explore how to control the sharing settings with the ArcGIS API for Python. You can learn much more about sharing your layers and using groups by accessing ArcGIS Online documentation.

Before you begin

The ArcGIS API for Python tutorials use Jupyter Notebooks to execute Python code. If you are new to this environment, please see the guide to install the API and use notebooks locally.

Complete the Import Data tutorial before you begin.


Create a new notebook

  1. Go to Esri Juptyter Notebooks and click New > Python 3 to create a new notebook.

    In each step below, type (or copy and paste) the commands into a new notebook cell and run the code by clicking run cell or pressing shift + Enter.

  1. Add the following code in a cell to import the ArcGIS API for Python.

    from arcgis.gis import GIS
  2. Log into ArcGIS Online by making a GIS connection to ArcGIS Online using your developer account. Replace username and password with your own credentials.

    gis = GIS("", "username", "password")
  3. Search for the Trialheads feature layer created as a challenge in the Import Data tutorial.

    search_results ='title: "Trailheads*" AND type: "Feature Service"')
  4. Retrieve the feature layer collection item from the list of results.

    feature_layer_item = search_results[0]
  5. Check the current sharing permissions of the layer by visiting its URL, feature_layer_item.url.

Search and update item sharing permissions

  1. Update the sharing permissions of the layer so that it's available to everyone.

  2. Check the feature layer URL that the permissions have been updated.

Congratulations, you're done!

Your notebook should now look something like this.


Create a new group and share the item with that group

In the ArcGIS API for Python, you can also programmatically create groups and share content to that group. Try creating a new group and sharing the item with that group.