Oh! I missed this bit on item.usage():
Apps that allow access to subscriber content through the organization
subscription show usage by credits.
I do see that when I try item.usage() on a locator service, the dataframe is empty, regardless of whether or not it's actually been used in the timeframe specified. It feels like you may be in Bug Report territory on that point.
Beyond that, though, I find it curious that the URL request is being made using the appID and not the ItemID from your content. And that the button appears in the Application section of the settings rather than the Usage tab.
Prior to the usage URL request, it looks like the ItemID is used to get the registeredAppInfo...
So, looking at the URL again. The usage request is happening at the portal level, with the appID being given as one of several variables.
Unfortunately, the /portals/[PortalID]/usage item is missing from the documentation, so we can only really guess how it's supposed to work. Nothing similar in the Python API either.
A Workaround
For now, I think you can still accomplish this by utilizing the requests library.
import requests
from datetime import datetime, timedelta
# Define span of report
enddate = datetime.now()
span = timedelta(days=7)
startdate = enddate - span
# There's a programmatic way to get a token, since you won't be doing this via the ArcGIS Python API, but I forgot its specifics
the_token = 'some_token'
app_id = 'some_id'
# Construct URL for request
reportURL = f'https://[your-org].maps.arcgis.com/sharing/rest/portals/[portalID]/usage?startTime={round(enddate.timestamp()*1000)}&endTime={round(enddate.timestamp()*1000)}&period=1h&appId={app_id}&vars=credits,num,bw&groupBy=etype,stype&f=json&token={the_token}'
# Get request
response = requests.get(reportURL)
The output of response.json() will be something like this:
{'startTime': 1633615200000,
'endTime': 1633618800000,
'period': '1h',
'data': []}
Which you can easily bring into something nicer like pandas.
pd.DataFrame(response.json()['data'])
Give this a try and let me know what it looks like when your app actually has credits to report. I get an empty dataframe, but in my case, that is accurate.
- Josh Carlson
Kendall County GIS