GET Account Usage

Use the “GET Account Usage” request method to retrieve data usage for your account over a specific date range. Note that this API Call returns the value of your account usage in bytes.

Authentication

Before you start, make sure that you have an API key with Read/Write privileges.

URL

Use the following URL format for your API call:

1
https://REGION.rest.logs.insight.rapid7.com/usage/organizations?from=YYYY-MM-DD&to=YYYY-MM-DD

Change REGION to match the data center for your account, such as us, eu, ca, or au.

URL Parameters

Change from and to to match the date range you want to use. Date values must be in ISO 8601 form, such as the following:

  • from = YYYY-MM-DD
  • to = YYYY-MM-DD

You can also leave these parameters blank if you want to retrieve account usage for the last 10 days. You can retrieve data up to the last 24 hours.

Data Parameters

There are no data parameters for this API call.

Success Response

The success response for this API call is “Code 200.” The content of the success code looks similar to the following:

1
{
2
"daily_usage": [
3
4
{
5
"usage": 134929550,
6
"day": "2018-12-13"
7
},
8
{
9
"usage": 133613742,
10
"day": "2018-12-12"
11
},
12
{
13
"usage": 133206061,
14
"day": "2018-12-11"
15
},
16
{
17
"usage": 126998155,
18
"day": "2018-12-10"
19
},
20
{
21
"usage": 131107328,
22
"day": "2018-12-09"
23
},
24
...
25
],
26
"period_usage": 2427260775,
27
"period": {
28
"to": "2018-12-19",
29
"from": "2018-12-01"
30
},
31
"id": "<internal ID>",
32
"name": "<Account name>"
33
}

Sample Call

The following is a sample API call for GET account usage:

1
import requests
2
import json
3
import time
4
API_KEY = 'YOUR API KEY'
5
def handle_response(resp):
6
response = resp
7
time.sleep(1)
8
if response.status_code == 200:
9
print json.dumps(resp.json(), indent=4)
10
else:
11
print response.status_code
12
13
def make_request(provided_url=None):
14
headers = {'x-api-key': API_KEY}
15
16
url = "https://us.rest.logs.insight.rapid7.com/usage/organizations?from=2018-12-01&to=2018-12-19"
17
req = requests.get(url, headers=headers)
18
return req
19
20
21
def get_usage():
22
req = make_request()
23
handle_response(req)
24
25
def start():
26
get_usage()
27
28
29
if __name__ == '__main__':
30
start()