Find Rest Endpoint for ArcGIS Online items with ArcGIS API for Python

349
3
Jump to solution
05-17-2020 01:50 PM
LidiaDudina2
New Contributor III

Has anyone tried to find Rest Endpoint for an ArcGIS Online item with ArcGIS API for Python (I am using Jupyter Notebooks). I am going through different parts of the API and don't see anything related to items' data source or rest endpoint. It is easy enough if done manually for one item at a time:

But I need to go through all of our content and find all registered items, which were published on our ArcGIS Server and then registers on AGOL. 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LidiaDudina2
New Contributor III

Resolved my onw question by looking into print(object.__dict__)
For anyone interested here is my code:

from arcgis.gis import GIS

import datetime

# login to your gis
gis = GIS("yourlink", "username", "password", proxy_host = "if you using one", proxy_port = 8080)

search_result = gis.content.search(query = '*', item_type="Feature Service",max_items=10000)

# list to record items 

list_of_items = list()


# as I am adding all in a table after, I need headings 

list_of_items.append(['title', 'id', 'views', 'created', 'owner', 'size', 'access', 'url', 'source url'])


for i in search_result:
  # using try as sometimes it goes upset and won't work... 

  try:

      # not all items have sourceUrl. For exmaple, hosted items don't have it. 
      if hasattr(i, 'sourceUrl'):
      source = i.sourceUrl
      unix_date =i.created # unix ms second date/time
      normal_date = datetime.datetime.fromtimestamp(unix_date / 1e3)

      # adding properties of one item as a list 
      list_of_items.append([i.title, i.itemid, i.numViews, normal_date, i.owner, i.size, i.access, i.url, i.sourceUrl])
 except:
    continue

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Honored Contributor

Lidia Dudina‌ ....

ArcGIS API for Python‌ might be a better place.  You should Share  or Move it there.


... sort of retired...
LidiaDudina2
New Contributor III

Thanks Dan! Moved.

LidiaDudina2
New Contributor III

Resolved my onw question by looking into print(object.__dict__)
For anyone interested here is my code:

from arcgis.gis import GIS

import datetime

# login to your gis
gis = GIS("yourlink", "username", "password", proxy_host = "if you using one", proxy_port = 8080)

search_result = gis.content.search(query = '*', item_type="Feature Service",max_items=10000)

# list to record items 

list_of_items = list()


# as I am adding all in a table after, I need headings 

list_of_items.append(['title', 'id', 'views', 'created', 'owner', 'size', 'access', 'url', 'source url'])


for i in search_result:
  # using try as sometimes it goes upset and won't work... 

  try:

      # not all items have sourceUrl. For exmaple, hosted items don't have it. 
      if hasattr(i, 'sourceUrl'):
      source = i.sourceUrl
      unix_date =i.created # unix ms second date/time
      normal_date = datetime.datetime.fromtimestamp(unix_date / 1e3)

      # adding properties of one item as a list 
      list_of_items.append([i.title, i.itemid, i.numViews, normal_date, i.owner, i.size, i.access, i.url, i.sourceUrl])
 except:
    continue

View solution in original post

0 Kudos