Links

Using the REST API

Testmo's REST API is a typical HTTP-based API to access Testmo's data model and create/update objects. Before directly accessing the HTTP API from your scripts and integrations, please first review the different options below on how to consume and use the API. There are simpler ways than using the API directly for the most common use cases.

Testmo CLI

The Testmo CLI is the easiest option to use Testmo's API and implement test automation integrations, submit automated test results from your CI/CD pipeline and implement advanced workflows.
For example, it's very easy to submit your automated test results in JUnit XML format (supported by pretty much any test automation tool) from the command line or CI/CD workflow:
Full example
Single line
Windows
$ export TESTMO_TOKEN=********
$ testmo automation:run:submit \
--instance https://<your-name>.testmo.net \
--project-id 1 \
--name "New test run" \
--source "frontend" \
--results results/*.xml
If you run this example on a single command line, make sure to remove the backspaces:
$ export TESTMO_TOKEN=********
$ testmo automation:run:submit --instance https://<your-name>.testmo.net --project-id 1 --name "Test run" --source "unittests" --results results/*.xml
On Windows, the command line uses a slightly different syntax to set a variable:
> set TESTMO_TOKEN=********
> testmo automation:run:submit --instance https://<your-name>.testmo.net --project-id 1 --name "Test run" --source "unittests" --results results/*.xml
Collecting log files ..
Found 1 result file with a total of 855 tests
Created new automation run (ID: 254)
Created new thread (ID: 608)
Sending tests to Testmo ..
Uploading: [|||||||||||||||||||||||||] 100% | ETA: 0s | 855/855 tests
Successfully sent tests and completed run
Marked the run as completed
The Testmo CLI also supports advanced workflows such as parallel testing, custom fields, submitting artifacts etc. The Testmo CLI tool can also directly launch your automation tool to measure test times, record exit statuses and capture the complete console output. Make sure to review its full documentation here:

JavaScript/NodeJS package

We also provide a ready-to-use JavaScript/NodeJS package to make it easier to consume and call the API from your custom scripts. The package is also used by the Testmo CLI tool, so it's always up-to-date. Here's a basic example on how to use the package:
var testmo = require('@testmo/testmo-api');
// Configure API client
const client = new testmo.ApiClient();
client.basePath = process.env.TESTMO_HOST;
client.authentications['bearerAuth'].accessToken = process.env.TESTMO_TOKEN;
// Request current user
const api = new testmo.UserApi(client);
const user = await api.get();
console.log(user);

HTTP API methods

You can also directly access Testmo's API from your custom scripts or command line if you prefer. To make it easier to consume the API, we also publish its OpenAPI schema to generate additional client libraries for more programming languages. Accessing the API is easy and you can directly call the HTTP methods and passing the authentication token:
$ TESTMO_TOKEN=********
$ curl -H "Authorization: Bearer $TESTMO_TOKEN" \
https://<testmo-name>.testmo.net/api/v1/user
You can learn more about authenticating against the API and generating API keys in Testmo's user interface.