Select to view content in your preferred language

ArcGIS Online Item Usage Reporting from Creation Date

906
1
03-02-2020 08:43 AM
Status: Open
WillIsaacs
Occasional Contributor

Usage reporting in ArcGIS Online is limited to 12 months as per the screen shot belowScreenshot of the maximum reporting time.

However, the data is available on the back end for all time views per Org Status page or on the Item Details page. 

suggest adding "All Time" for date ranges for reporting on the Item Usage Page

1 Comment
ThomasColson

This is already implemented with the following code. You'll need to convert the dates you want to UNIX time stamps. The problem with "More than a year" is the API request is limited to 10000 items returned, so when I run this, I have to divide it into 6-month chunks (going back to 2014) in order to get everything. 

from datetime import timedelta
import sys
import logging
#now_dt = datetime.datetime.utcnow()
#then_dt = now_dt - timedelta(days=int(input_days))
#now = 1567084745
#then = 1546300800
portal = 'https://www.arcgis.com'
username = 'users'
password = 'pass'
gis = GIS(portal, username, password)




#itemsList = gis.users.search(query="*", max_users=10000)
itemsList = gis.content.search(query = 'modified: [1576713601000 TO 1577836799000]', max_items=10000)
fields = ['ID','Title', 'Type', 'Owner', 'Access', 'NumberViews', 'Created', 'Size']
def itemRetrieval(arr, csvPath):
 try:
 with open(csvPath, 'w', encoding='utf-8', newline = '') as outfile:
 csvfile = csv.writer(outfile)
 csvfile.writerow(arr)
 for item in itemsList:
 print(item)
 row = [item.id,
 item.title,
 item.type,
 item.owner,
 item.access,
 item.numViews,
 item.created,
 item.size]
 csvfile.writerow(row)
 except Exception as error: 
 print('The following error occurred: ', error)
itemRetrieval(fields, 'AGOL_USE_UPDATE.csv')