By popular demand we’ve enabled an API to allow you to extract data from your reports and embed it in your own web properties as a report or dashboard. This is going to be a premium feature, but for beta users it’s available at the moment for free, and for people signing up when we go live you’ll get 30 days for free.
At the moment, it is fairly simple. To access it, you need create an API key by selecting “Edit Profile” from the dropdown underneath the “@<username>” menu in the top banner.
To use each of the following APIs, either add:
Authorization: Bearer <api key>
to the headers of each HTTP request, or _token=<api key> in the parameters of the request. NB: if you include a parameter “debug” in the request, the output will be pretty-printed for easy human reading.
Report List:
GET https://client.apimetrics.io/api/1/reports/
returns a list of your reports.
Example output:
[fusion_builder_container hundred_percent="yes" overflow="visible"][fusion_builder_column type="1_1" background_color="" border_size="" border_color="" spacing="yes" padding="" margin_top="0px" margin_bottom="0px" class="" id="" hide_on_mobile="no" center_content="no" min_height="none"][ { "id": "agpzfnZpYXRlc3RzchcLEgpUZXN0UmVwb3J0GICAgIDJ6a8JDA", "last_update": "2013-08-30T03:46:47.875600", "name": "Test Report One", "group_list": [ { "name": "Group A", "test_list": [ "agpzfnZpYXRlc3RzchcLEgpUZXN0U2V0dXAyGICAgID-rvsIDA" ] } ], "created": "2013-08-30T03:46:08.247770" } ]
Report Stats:
GET https://client.apimetrics.io/api/1/reports/<report_id>/
returns the stats associated with your report.
Optional parameters:
- kind – HOUR, DAY, WEEK, MONTH or YEAR
- time – ISO-formatted string of the time you want stats for. (e.g. 2013-10-15T00:00)
The output contains the tests in the groups as per your report definition. The stats are collated by “ALL”, which is the stats for all tests results, and then by each possible result type. Possible result types are:
- “UNABLE_TO_RUN” – if the test didn’t run.
- “DOWNLOAD_ERROR” – if our server was unable to contact the API
- “HTTP_REDIRECT_ERROR” – if there was a problem following HTTP redirects
- “HTTP_CLIENT_ERROR” – if there was a 4xx HTTP response code
- “HTTP_SERVER_ERROR” – if there was a 5xx HTTP response code
- “HEADER_ERROR” – if there was an unexpected result in the HTTP headers
- “CONTENT_ERROR” – if there was unexpected content
- “COMPLETE” – the test passed successfully.
Example output:
{ "kind": "DAY", "name": "Test Report One", "created": "2013-08-30T03:46:08.247770", "group_list": [ { "name": "Group A", "test_list": [ { "stats": { "ALL": { "count": 6, "avg_latency": 149, "max_latency": 169 }, "COMPLETE": { "count": 6, "avg_latency": 149, "max_latency": 169 } }, "id": "agpzfnZpYXRlc3RzchcLEgpUZXN0U2V0dXAyGICAgID-rvsIDA", "last_run": "2013-10-15T01:10:00.440590", "name": "Test Name" } ] } ], "last_update": "2013-08-30T03:46:47.875600", "time": "2013-10-15T00:00:00", "id": "agpzfnZpYXRlc3RzchcLEgpUZXN0UmVwb3J0GICAgIDJ6a8JDA" }
Test List:
GET https://client.apimetrics.io/api/1/tests/
returns a list of all your tests.
Example output:
[ { "auth_key": "agpzfnZpYXRlc3RzchYLEglBdXRoVG9rZW4YgICAgJ7lxwsM", "name": "Soundcloud User Get me XML", "parameters": [], "tags": [], "deleted": false, "id": "agpzfnZpYXRlc3RzchcLEgpUZXN0U2V0dXAyGICAgICRhKMJDA", "created": "2013-08-21T01:19:54.544150", "file_key": null, "last_update": "2013-08-27T23:51:34.915200", "headers": [], "public": true, "request_type": "application/x-www-form-urlencoded", "frequency": -1, "http_method": "GET", "response_type": "text/xml", "last_run": null, "active": false, "api_url": "https://api.soundcloud.com/me", "email_on_fail": [], "service_key": "agpzfnZpYXRlc3RzchoLEg1TZXJ2aWNlQ29uZmlnGICAgICRnKEIDA", "description": null }, ... ]
Test Results:
GET https://client.apimetrics.io/api/1/results/<test_id>/
returns the stats associated with your report.
Optional parameters:
- result_filter – return only results with a specific result type
Example output:
[ { "fatal_messages": [], "created": "2013-08-27T23:51:37.397670", "start_time": "2013-08-27T23:51:37.516070", "messages": [ "Fetch URL https://api.soundcloud.com/me?oauth_token=1-41341-10910116-b80279fc35b3873", "Server returned HTTP code 200", "Expecting response type text/xml, received response type application/xml.", "Successfully parsed response as XML." ], "last_update": "2013-08-27T23:51:37.871300", "test_length": 169, "end_time": "2013-08-27T23:51:37.685900", "test": "agpzfnZpYXRlc3RzchcLEgpUZXN0U2V0dXAyGICAgICRhKMJDA", "http_code": 200, "result": "COMPLETE" }, ... ]