LoadNinja REST API

Last modified on August 06, 2024

LoadNinja REST API (or LoadNinja API) is used for accessing LoadNinja data and for integration with external systems. It is available to all LoadNinja customers.

Swagger UI

The API has a web interface that contains and describes all the available API operations and parameters, and allows you to make API calls and view the returned data.

To access the API web interface, go to:

https://app.swaggerhub.com/apis-docs/smartbear/loadninja/1.0

Keep in mind that the web interface accesses and changes real-world data.

Base URL and scheme

To access the API from external tools and utilities, use the following base URL:

https://api.loadninja.com/v1

The LoadNinja API uses HTTPS as the transfer protocol (scheme).

Authorization

Each request to the LoadNinja API should include an authorization header with a 32-symbol API key. To authenticate, append the API key as the authorization header to your request in the following format:

authorization: 123aa578-aa2b-bb2c-becf-123456c122
  1. In LoadNinja, go to  > Settings.

  2. Switch to the API Keys tab.

  3. Click Generate.

  4. Confirm this action in the subsequent dialog.

  5. After you do this, LoadNinja will generate an API key.

    • To copy the key to the clipboard, click .

    • To view the key, click .

    • To stop using this key and create a new one, click Regenerate, then confirm this action in the subsequent dialog.

Data format headers

LoadNinja API operations use the JSON data format for request bodies.

To provide the server with the correct information about the body format, append the following header to the requests that have a body:

Content-Type: application/json

Since most operations also return JSON data, please add the Accept header to your requests as well:

Accept: application/json

Response codes

LoadNinja API uses the following status codes for responses:

Status code Description
200 The request was completed successfully. LoadNinja sent the expected response.
400 The request is missing the authorization header, or the authorization key is invalid.
500 The request was not processed due to an internal error. For example, the client tried to access a non-existing resource, or used a wrong HTTP method.

Note: An error response may contain additional information on the error within the request body.

Response format

When you use LoadNinja API for your tests, the response format depends on the size of the test. For small and medium-sized tests, the format is raw JSON. However, for more complex tests or when dealing with a larger number of users - where the size of the data transferred exceeds 6MB (as limited by AWS Lambda) - the JSON data is compressed.

The response is returned in JSON, but the endpoint /test-run/{test-run-id}/raw-stats is an exception. Its response is compressed, so it must be decompressed.

To decompress data, you need:

  • Node.js installed (version 14 or higher)

  • Decompression script (click here to view the file)

    Note: This script is developed and maintained by the LoadNinja team. It uses one dependency - JsZip.

After installing Node, follow these steps:

  1. Open Command Line Interface (CLI).

  2. Navigate to the folder that containing the decompression script using the cd command.

  3. In the CLI, write:

    node extract_test_data.js <json_file_with_compressed_data> <extracted_json_file>

    Make sure to replace <json_file_with_compressed_data> with the actual name of your compressed JSON file and <extracted_json_file> with the desired name for the decompressed file.

  4. Click Enter. The script will decompress the data and place it in the specified <extracted_json_file>.

See Also

LoadNinja Tutorial
Typical Use Cases

Highlight search results