API
The API gives users the ability to start tests using simple HTTP calls. To navigate to the API instructions, click on the “API” tab in the top menu bar:
When you access the page, you will see your authorization token, examples of common API requests, and more:
Item | Description |
|
---|---|---|
Authorization Token | Access token to the API for your account |
|
Technical Documentation | Link to the API reference | |
Examples | Sample API calls |
|
Example API Calls
The API page includes a number of useful API calls. This section describes several calls which can be used to perform useful functions, such as starting a load test script, retrieving metrics from a completed test, or creating and running a Scenario. Of course, complete documentation is available on the dedicated API documentation page.
Start a Single Load Test
A single load test can be performed by calling the “selfservicejobs/preset” endpoint. Specify a preset (that is, a set of common configuration settings), a script file in .class or .zip format, a date and time to start the test, and a set of parameters to override from the preset. For example:
curl -X POST -H "Content-Type: application/json; charset=utf-8" --url "https://api-alt-us1.apicasystems.com/v1/selfservicejobs/preset/?token={users_api_token}" -d "{\"PresetName\":\"Preset Name\",\"RunnableFileName\":\"loadtest.class\",\"ScheduledDate\":{\"Year\":2014,\"Month\":7,\"Day\":1,\"Hour\":8,\"Minute\":0}}"
Retrieve the Results of a Single Load Test
A summary of a single load test can be retrieved by calling the “selfservicejobs/{selfServiceJobId}/summary” endpoint. Specify a self service job ID, which can be retrieved using a variety of API calls. For example, https://api-alt-us1.apicasystems.com/v1/Help/Route/GET-selfservicejobs-filter_fromUtc returns the Job IDs for every Job which was finished within a certain specified timeframe. The summary includes information such as the timestamp of the completed Job, the name of the Project and Test Instance to which the Job belongs, and the status of the job (whether it passed or failed). For example:
curl -X GET --url "https://api-alt-us1.apicasystems.com/v1/selfservicejobs/{jobId}/summary/?token={users_api_token}"
Check the Status (Queued, Running, Finished) of a Load Test
The status of a specified Load Test can be useful for automation purposes when trying to determine whether a certain job has finished running by calling the “testresultdata/jobstatus/{jobId}” endpoint. Specify a self service job ID; generally this call will be used on a test which has been recently started. If that’s the case, the Job ID can be found in the response body of the API call which was used to start the job (https://api-alt-us1.apicasystems.com/v1/Help/Route/POST-selfservicejobs-preset):
{
"jobid": 153758,
"exception": ""
}
The call is useful for determining whether a test has passed or failed and if it failed, any pertinent error messages that specify the cause of the failure. The following is an example call to the testresultdata/jobstatus/{jobId} endpoint:
Run a Scenario Which Has Already Been Defined
A scenario which has already been configured in the Load Test Portal can be executed from the API via the “scenario/run” endpoint.
The scenario to run is specified in the Request Body using either a Scenario Name or a Scenario ID. Generally, the scenario name will be used in the request body along with a set of options which define how the scenario should be run. The scenario ID will be returned in the Response Body of the API call and can be used on subsequent calls to the API to get the status of or abort the scenario.
Return Load Test Metrics
A number of metrics related to a load test result can be returned from the LTP API using the following call:
Metric | Description |
---|---|
Average network connect time (ms) | Displays the time to open a new network connection to the web server before data is sent (socket open time) |
Average network throughput | The average value of the total network bandwidth which was generated by the Load Test |
Average network throughput unit of measurement | The unit of measurement of the average network throughput, e.g. KBit/s or MBit/s |
Average response time per loop (s) | The measured average response time per web surfing session. The average is calculated over all web pages, simulated users and loops |
Average response time per page (s) | The measured average response time per page. The average is calculated over all web pages, simulated users and loops |
Average session time per loop (s) | The measured average time of the web surfing session per executed Load Testing Loop - including all users' think times. The average is calculated over all simulated users and loops |
Http keep-alive efficiency | Displays the percentage of re-used network connections. This value is only greater than zero if the HTTP protocol version 1.1 has been used and the web server supports the 'keep-alive' option |
Session failure rate (soft errors, %) | The proportion of failed loops with errors that do not hinder the page from being downloaded, e.g. a missing style sheet or image file. Soft errors do not block the completion of the loop |
Total failed loops | The number of loops, i.e. web surfing sessions, which have failed |
Total http(s) calls | The total number of HTTP(S) calls during the load test |
Total passed loops | The number of loops, i.e. web surfing sessions, with no errors |
Total transmitted bytes | The total amount of data transmitted during the URL calls of the load test |
Url error rate (hard errors, %) | The proportion of failed loops with fatal errors that block the page load, e.g. HTTP 404 or 500. Hard errors block the completion of the loop |
Web transaction rate (Hits/s) | The measured number of successful completed URL calls per second (hits per second), counted over all simulated users |
Cannot find what you're looking for? Send an E-mail to support@apica.io.