Catchpoint has two types of APIs, a push (subscriber) API and a pull REST API. This module is a wrapper for the REST API.
API documentation is available to Catchpoint customers.
Tested on Python 2.7.5
Modules:
- datetime
- pytz
- requests
python setup.py install
# import the module
import catchpoint
# define your catchpoint credentials
creds = {
'client_id': 'yourclientid',
'client_secret': 'yourclientsecret'
}
# create a Catchpoint object
cp = catchpoint.Catchpoint()
# query the API, always pass the creds
print cp.favorite_charts(creds)
print cp.favorite_details(creds, myfav)
Method | Description | Parameters |
---|---|---|
raw | Retrieve the raw performance chart data for a given test for a time period. | creds, testid, startTime, endTime, tz="UTC" |
favorite_charts | Retrieve the list of favorite charts. | creds |
favorite_details | Retrieve the favorite chart details. | creds, favid |
favorite_data | Retrieve the data for a favorite chart, optionally overriding its timeframe or test set. | creds, favid, startTime=None, endTime=None, tz="UTC", tests=None |
nodes | Retrieve the list of nodes for the API consumer. | creds |
node | Retrieve a given node for the API consumer. | creds, node |
aggregated | Retrieve aggregated data for a list of tests for a time period. | creds |
Param | Type | Description |
---|---|---|
creds | dict | Contains the Catchpoint client_id and client_secret |
testId(s) | str / list of str | The Catchpoint test ID |
favId | str | The Catchpoint favorite ID |
startTime | str or int | UTC formatted ("2014-06-19T12:51:37Z") time to begin requested dataset. Can be expressed as a negative integer when endTime = 'now'. |
endTime | str | UTC formatted ("2014-06-19T12:51:37Z") time to end requested dataset. Can be expressed as 'now' to use current time. |
tz | str | Optionally set the timezone to correlate to the Catchpoint test's configuration. |
tests | str | Specify a comma-separated list of tests when retreiving a favorite chart. |
node | str | The Catchpoint node id. |
aggregationType | str | Either 'Day' or 'Minutes15' |
Catchpoint's API requires specific UTC formatted timestamps when requesting datasets. These can be made relative by setting startTime
to a negative integer that represents number of minutes into the past, and set endTime
to 'now'.
Example for retreiving the last 60 minutes of data:
cp = catchpoint.Catchpoint()
myfav = "12345"
startTime = -60
endTime = "now"
print cp.favorite_data(creds, myfav, startTime, endTime)
GPL v2