List hosted items and the REST endpoint URLs using ArcGIS API for Python

Last Published: March 17, 2023


Contents from a portal can be added to a different portal using ArcGIS API for Python with the add() function from the arcgis.gis.ContentManager module. Within the add() function, required parameters include the REST endpoint URL of the desired item. The REST endpoint URL is available in the following template:

http://<host name>/arcgis/rest/<ServiceName>

Retrieving the URL of all the items in a portal can be tedious when a large number of services is involved.

This article provides an automated process to retrieve the REST endpoint URLs of all feature layers or web maps in a portal using the arcgis.gis module.


  1. Import the necessary modules.
import arcgis
from arcgis.gis import GIS
  1. Specify the user credentials and connect to the portal.
user = "username"
password = "password1"
url = "https://< a portal url >"

gis = GIS(url, user, password)
  1. Search and list all the feature layers available.
fcs ="owner:" + user, item_type="Feature Layer", max_items=10)
  1. Iterate through the list and return the REST URLs.
for list in fcs:
    print (fcs[i].url)

Article ID:000016853

  • Portal for ArcGIS 10 8
  • Portal for ArcGIS 10 7
  • ArcGIS API for Python 1 x
  • ArcGIS Server
  • ArcGIS Online
  • Portal for ArcGIS 10 6

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic