API to gain credit information

11-29-2013 04:22 AM
New Contributor II
Hi Guys,

I'm interested, if there is an API existing or in developement to determine programmatically, how many credits are left on your account. Also it would be interesting, to get all statistical information, that is displayed in your account (all these diagrams and graphs) via an interface into your server-side applications, for example to get a warning, if you are running low on credits.

Does something like this exist?


Martin Scherpinski

alta4 Geoinformatik AG
Frauenstra??e 8-9
54290 Trier/Germany
tel: +49.651.96626-0
fax: +49.651.96626-26
Tags (2)
0 Kudos
4 Replies
Regular Contributor III
What I did was to run Fiddler and then logged on to ArcGIS Online and reviewed my credits/usage.  Doing this will show what calls you have to make to get the information that you need.

This is one of the key calls:


Which is documented here:


The problem with the above link is that the documentation is incomplete.  I suspect that this is because this API is intended to work for both ArcGIS Online (which has additional information such as availableCredits) as well as portal which is an on site version of ArcGIS Online.  Regardless, the online documentation is not well done.

Here is another key call:


Best of luck!
0 Kudos
Esri Regular Contributor
We don't document the credit parameters in the Portal API because it is possible they may change at anytime without notice, to support various applications and features of ArcGIS Online. Everything documented in the ArcGIS REST API is intended for broad use and is carefully updated in order to not affect backwards compatibility with applications.

Others have requested to support credit queries through the API, and I would strongly encourage you to vote up this idea, as well as provide any additional context in your comments on how you would like to use the API.

Provide an API for calculating ArcGIS Online Credit usage

Thank you,
0 Kudos
New Contributor II
Hi Andrew,

as I understood the approach you posted, it aims to the application user itself to provide information about the credits to them (e.g. in a popup that says "your route will cost 5 credits). We are more interested in an API to inform the developers and administrators about the usage, for example that any server hosting a backend that will connect to AGO could determine when credits are running low and then inform the admin via mail or so.

The ideas page is indeed a good starting point to find the right approach:

in combination with this: https://c.na9.visual.force.com/apex/ideaView?id=087E00000004WPQIA2 it would be a great improvement to AGO services


Martin Scherpinski

alta4 Geoinformatik AG
Frauenstra�?e 8-9
54290 Trier/Germany
tel: +49.651.96626-0
fax: +49.651.96626-26
0 Kudos
New Contributor III

This class works:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net;
using System.Windows.Forms;
using System.Net.Http;
using System.Net.Http.Headers;
using System.IO;
using System.Runtime.Serialization.Json;
using System.Web;
using System.IdentityModel.Tokens;
using System.Xml;

namespace GeocodeForm
public class AGOL
private string _token;
private string _username;
private string _password;
public organizationInformation orgInfo;

public string GetAGOLToken(string UserName, string PassWord)
_username = UserName;
_password = PassWord;
_token = GetToken(UserName, PassWord);
orgInfo = _getOrgInfo(_token);

MessageBox.Show(orgInfo.availableCredits.ToString(), "Available Credits", MessageBoxButtons.OK);

return _token;

public organizationInformation _getOrgInfo(string token)
var data = new NameValueCollection();
data["token"] = token;
data["f"] = "json";

organizationInformation x = Deserialize<organizationInformation>(_getResponse(data, "http://www.arcgis.com/sharing/rest/portals/self"));

return x;

private static T Deserialize<T>(string json)
var instance = Activator.CreateInstance<T>();
using (MemoryStream ms = new MemoryStream(System.Text.Encoding.Unicode.GetBytes(json)))
DataContractJsonSerializer serializer = new DataContractJsonSerializer(instance.GetType());
return (T)serializer.ReadObject(ms);


private string _getResponse(NameValueCollection data, string url)
string responseData;
var webClient = new WebClient();
var response = webClient.UploadValues(url, data);

// Get the response.
responseData = System.Text.Encoding.UTF8.GetString(response);
return responseData;

public string GetToken(string username, string password)

var data = new NameValueCollection();
data["username"] = username;
data["password"] = password;
data["referer"] = "https://www.arcgis.com";
data["f"] = "json";

var jssD = new System.Web.Script.Serialization.JavaScriptSerializer();

TokenInfo x = jssD.Deserialize<TokenInfo>(_getResponse(data, "https://arcgis.com/sharing/rest/generateToken"));
string jeff = x.token.ToString();

return x.token;

public class TokenInfo
public string token { get; set; }
public long expires { get; set; }
public bool ssl { get; set; }

public class organizationInformation
public string access { get; set; }
public bool allSSL { get; set; }
public double availableCredits { get; set; }
public string backgroundImage { get; set; }
public string basemapGalleryGroupQuery { get; set; }
public string bingKey { get; set; }
public bool canListApps { get; set; }
public bool canListData { get; set; }
public bool canListPreProvisionedItems { get; set; }
public bool canProvisionDirectPurchase { get; set; }
public bool canSearchPublic { get; set; }
public bool canShareBingPublic { get; set; }
public bool canSharePublic { get; set; }
public bool canSignInArcGIS { get; set; }
public bool canSignInIDP { get; set; }
public string colorSetsGroupQuery { get; set; }
public bool commentsEnabled { get; set; }
public long created { get; set; }
public string culture { get; set; }
public string customBaseUrl { get; set; }
public int databaseQuota { get; set; }
public int databaseUsage { get; set; }
public string description { get; set; }
public string featuredGroupsId { get; set; }
public string featuredItemsGroupQuery { get; set; }
public string galleryTemplatesGroupQuery { get; set; }
public string helpBase { get; set; }
public string homePageFeaturedContent { get; set; }
public int homePageFeaturedContentCount { get; set; }
public int httpPort { get; set; }
public int httpsPort { get; set; }
public string id { get; set; }
public string ipCntryCode { get; set; }
public bool isPortal { get; set; }
public string layerTemplatesGroupQuery { get; set; }
public int maxTokenExpirationMinutes { get; set; }
public long modified { get; set; }
public string name { get; set; }
public string portalHostname { get; set; }
public string portalMode { get; set; }
public string portalName { get; set; }
public object portalThumbnail { get; set; }
public string region { get; set; }
public bool showHomePageDescription { get; set; }
public string staticImagesUrl { get; set; }
public long storageQuota { get; set; }
public long storageUsage { get; set; }
public bool supportsHostedServices { get; set; }
public bool supportsOAuth { get; set; }
public string symbolSetsGroupQuery { get; set; }
public string templatesGroupQuery { get; set; }
public string thumbnail { get; set; }
public string units { get; set; }
public string urlKey { get; set; }
public bool useStandardizedQuery { get; set; }

} // end class

0 Kudos