A modern, type-safe TestRail API client written in TypeScript.
Note
Some TestRail API endpoints may differ from the official documentation. Our implementation is based on actual responses obtained through reverse engineering.
npm install testrail-modern-client
import { TestRailClient } from 'testrail-modern-client';
const client = new TestRailClient({
host: 'https://your-instance.testrail.io',
email: 'your-email',
password: 'your-password', // or API key
});
// Get a test case
const testCase = await client.cases.get(1);
// Create a test run
const run = await client.runs.add(1, {
name: 'Test Run',
include_all: true,
});
TestRail API uses HTTP basic authentication. There are two ways to authenticate:
Generate an API key in TestRail under "My Settings". Then use your email address and the API key as password:
import { TestRailClient } from 'testrail-modern-client';
const client = new TestRailClient({
host: 'https://your-instance.testrail.io',
email: '[email protected]',
password: 'your-api-key' // API key from My Settings
});
Use your TestRail email and password. Note: This might be your Active Directory or LDAP password depending on your TestRail configuration.
import { TestRailClient } from 'testrail-modern-client';
const client = new TestRailClient({
host: 'https://your-instance.testrail.io',
email: '[email protected]',
password: 'your-password'
});
Important: Always use HTTPS for your TestRail instance to ensure secure authentication. TestRail Hosted accounts use HTTPS by default.