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.
Solved! Go to Solution.
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 headingslist_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
Lidia Dudina ....
ArcGIS API for Python might be a better place. You should Share or Move it there.
Thanks Dan! Moved.
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 headingslist_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