usage.api.history
The usage.api.history command gets historical API usage statistics.
API usage history can be requested by specifying the following:
-
A definite time period using a start and end date
-
A time period defined by the "last period of time" style query (fir example, last "24h")
TR50 Request
// Definite time period request
{
"get": {
"command": "usage.api.history",
"params": {
"includeSubOrgs": false,
"showAll": false,
"start": "2014-03-27T00:00:00.000-00:00",
"end": "2014-03-28T00:00:00.000-00:00",
"series": "hour"
}
}
}
// Last period of time request
{
"get": {
"command": "usage.api.history",
"params": {
"includeSubOrgs": false,
"showAll": false,
"last": "24h",
"series": "hour"
}
}
}
Request Parameters
Name |
Type |
Required |
Description |
---|---|---|---|
dimension |
String |
|
If set to "org" displays the counters grouped by org. |
includeSubOrgs |
Boolean |
|
If sub-org totals should be included in the results. |
showAll |
Boolean |
|
If all organizations should be included in the results. Requires Super-Ops. |
last |
String |
|
Valid time units are seconds (s), minutes (m), hours (h), or days (d). |
start |
String |
|
Timestamp. |
end |
String |
|
Timestamp. |
series |
String |
|
How the data should be aggregated. Valid options are "hour" and "day". Defaults to "hour". |
TR50 Response
If the command is sent successfully a success message and the statistics are returned. Otherwise, an error and error message will be returned.
{
"get": {
"success": true,
"params": {
"counters": {
"usage": [0, 0, 0, 0, 1],
...
},
"total": 42,
"ts": [
"2014-01-20T08:00:00-05:00",
"2014-01-20T09:00:00-05:00",
"2014-01-20T10:00:00-05:00",
"2014-01-20T11:00:00-05:00",
"2014-01-20T12:00:00-05:00"
]
}
}
}
Response Parameters
Name |
Type |
Description |
---|---|---|
counters |
Object |
An object, keyed by the name of the service, that has an array expressing the number of API calls that took place during the time period in the corresponding position in the ts array below. |
total |
Integer |
The total of all values in the counter object structure. |
ts |
Array |
An array of the timestamps associated with the counter values. |