Usage reporting in ArcGIS Online is limited to 12 months as per the screen shot below
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
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
#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):
with open(csvPath, 'w', encoding='utf-8', newline = '') as outfile:
csvfile = csv.writer(outfile)
for item in itemsList:
row = [item.id,
except Exception as error:
print('The following error occurred: ', error)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.