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
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')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.