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:
1https://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": [34{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:
1import requests2import json3import time4API_KEY = 'YOUR API KEY'5def handle_response(resp):6response = resp7time.sleep(1)8if response.status_code == 200:9print json.dumps(resp.json(), indent=4)10else:11print response.status_code1213def make_request(provided_url=None):14headers = {'x-api-key': API_KEY}1516url = "https://us.rest.logs.insight.rapid7.com/usage/organizations?from=2018-12-01&to=2018-12-19"17req = requests.get(url, headers=headers)18return req192021def get_usage():22req = make_request()23handle_response(req)2425def start():26get_usage()272829if __name__ == '__main__':30start()