Credit usage reports per user using the Python API

2954
5
07-26-2019 11:02 AM
PeterGamberg1
Esri Contributor

Is it possible to return credit usage reports for each user in an Arcgis Online organization using the Python API? And if so, can it be returned for a specific period of time?

The credit manager class just returns the credit usage for the entire organization.

Tags (1)
0 Kudos
5 Replies
MehdiPira1
Esri Contributor

Hi Peter Gamberg‌,

you can use the following code to check the credits availability for each user:

#Checking credits assigned and available to a user
api_acc = gis.users.get('USERNAME')
"""When you turn on credit budgeting (using the enable() method), 
the User object gets additional properties to 
indicate the assignedCredits and remaining avialableCredits. 
Thus, you can verify as shown below:"""
api_acc.assignedCredits
------------------------------------------------------------------------------
api_acc.availableCredits

"""As the user continues to use the credits, the availableCredits 
property can be used to check how much is available for that account. 
If a user does not have a limit set, then the total available credits 
in the org become their available credits. The account shown below as 
not custom limit, hence, it inherits the org's total limit.‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍"""
by Anonymous User
Not applicable

I have added an idea for this as I was just trying to do this also. Please upvote it here!

0 Kudos
Per_Åke_MattiasWallin
New Contributor III

Use gis.admin.usage_reports.users().  See the sample @ https://community.esri.com/thread/241589-user-credit-usage?start=0&tstart=0 

LindseyDanforth_Boulder
New Contributor II

I have tried using gis.admin.usage_reports.users() and I get strange results. I get a smaller list than what it in our organization and I get lots of names outside of our organization. I can't figure out why its returning such an odd list.

0 Kudos
MJBiazar
Esri Contributor

Hi @PeterGamberg1 I know this is an old post but I just wanted to share some info for reference. To create a credit report for users in your ArcGIS Online organization you can create a credit report in ArcGIS Online or similarly in ArcGIS API for Python using gis.admin.usage_reports.credit. You can specify the start time or the timeframe for your report if you need to:

credit(start_time=Nonetime_frame='week'export=False)

  • start_time: optional datetime, the time to step back from. If None, the current time is used.
  • time_frame: >optional string, is the timeframe report to create. Allowed values: today, week (default), 14days, 30days, 60days, 90days, 6months, year
  • export: optional boolean, if True, a csv is generated from the request. If False, a Panda’s dataframe is returned

For more details, please see our documentation:

https://developers.arcgis.com/python/api-reference/arcgis.gis.admin.html#agolusagereports

 

Best,

MJ

0 Kudos