npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dichovsky/testrail-api-client

v10.1.0

Published

Type-safe ESM TestRail API client and CLI for Node.js

Readme

TestRail API Client

CI npm version TypeScript License: MIT

@dichovsky/testrail-api-client supplies a TypeScript SDK and the testrail CLI for the TestRail REST API. Use the CLI for shell scripts and CI. Use the SDK for typed application code, shared caching, and request controls. The package uses ESM and has one runtime dependency: Zod.

Install

The package requires Node.js 26 or newer. CI tests Node 26 on Linux, macOS, and Windows.

npm install @dichovsky/testrail-api-client

Set credentials for either quick start:

export TESTRAIL_BASE_URL="https://your-domain.testrail.io"
export TESTRAIL_EMAIL="[email protected]"
export TESTRAIL_API_KEY="…"

Do not put the API key in command arguments or logs. The CLI also accepts the API key through standard input.

Upgrading to 10.1.0

Global user lists now support bounded pagination. The Node.js 26 requirement and the 10.0.0 migration steps stay unchanged.

  • users.getUsers() and CLI user list still return the users from one response. Use users.getAllUsers() or user list --all to read all global users within the pagination safety limits.
  • Use users.getUsersPage() or user list --page to read one global page with its pagination metadata. Requested pages stay limited to 250 items. The client does not support cursor pagination.
  • Project user reads keep one response. users.getUsers(projectId) ignores extra runtime arguments, as version 10.0.0 did. Its TypeScript overload accepts only the project ID. The CLI rejects pagination flags with user list --project-id before authentication.

See SDK pagination and CLI pagination for options and safety limits.

Upgrading to 10.0.0

  • Upgrade application, CLI, and CI runtimes to Node.js 26 or newer.
  • Remove caller cleanup for file descriptors that you pass to SDK upload methods. Remove this cleanup also for calls that fail before the client sends a request. The SDK now owns those descriptors from the start of the call. See upload ownership.
  • Replace parse() overrides for endpoint responses with onSchemaMismatch for mismatch reports or strict validation. Apply response transformations after you await the endpoint method. See response validation for affected behavior and examples.
  • Catch TestRailApiError with status === 0 for DNS resolver failures. The client does not throw TestRailValidationError for these failures now.
  • Pass a baseUrl without a query string or fragment.
  • Remove timeout, bodyTimeout, deadlineAt, and cacheVariant from objects that you pass to client.request(). The argument type of client.request() does not declare these fields now. Use client.withTimeout(ms) for a per-request timeout.
  • Make sure that typeof result.quality_rating === 'number' is true before you use the field as a number. The field can now be an object of scores.
  • Expect TestRailValidationError before any request for an empty or invalid case_ids or test_ids list in bulk writes. Expect the same error for an empty addCases() array.
  • Correct CLI scripts that pass one of these arguments, because the command now exits 1:
    • A malformed --limit or --offset.
    • An empty --timeout.
    • A positional argument to install-skill or uninstall-skill.

The project tests the published declaration files with TypeScript 7. The project does not test other compiler versions. TypeScript is not a runtime or peer dependency of the package. See the changelog for the full release scope and affected methods.

Quick start (SDK)

The example reads a project and then releases the timers and cache of the client:

import { TestRailClient } from '@dichovsky/testrail-api-client';

const client = new TestRailClient({
    baseUrl: process.env['TESTRAIL_BASE_URL']!,
    email: process.env['TESTRAIL_EMAIL']!,
    apiKey: process.env['TESTRAIL_API_KEY']!,
});

try {
    const project = await client.projects.getProject(1);
    console.log(project.name);
} finally {
    client.destroy();
}

The SDK supplies compile-time types for write payloads. For dynamic input, call the exported payload schema's .parse(input) before the write. See the SDK guide for writes, configuration, pagination, and error handling.

Quick start (CLI)

If the package is installed locally, run commands through npx testrail:

npx testrail project list
npx testrail case get 42

# Validate and preview a write without calling TestRail.
npx testrail run add 5 --data '{"name":"CI build","include_all":true}' --dry-run

npx testrail run --help

The CLI validates write payloads with Zod and prints JSON by default. Remove --dry-run to send the write. Destructive actions require both --yes and TESTRAIL_ALLOW_DESTRUCTIVE=1. See the CLI guide for authentication, payload files, output formats, and destructive commands.

Behavior to know

| Topic | Default behavior | | ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | Lists | A list method returns the items from one response. Use getAll*() or CLI --all for bounded pagination. | | Responses | Entity-field mismatches are advisory. CLI --strict-responses makes them errors. Paginated lists still validate their outer structure. | | Caching | The client caches eligible GET responses for five minutes. Dispatched writes clear the cache, with or without an error. Aggregate reads bypass the cache. | | Retries | Ordinary GET requests retry transient failures. JSON writes and report execution retry only on 429. Uploads never retry. | | Connections | The client blocks private hosts and redirects. See the networking guide for trusted private servers, proxies, and custom certificates. |

Examine the server state before you retry an uncertain write. A response-validation error can occur after the write executes. The guides below explain limits, exceptions, and configuration.

Documentation

| I want to… | Read | | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Configure the SDK, write data, or handle errors | SDK guide | | Use CLI flags, pagination, or diagnostic files | CLI guide | | Connect through private networks, DNS, or proxies | Networking · DNS · Proxies and certificates | | Find a command or a worked example | Command reference · Recipes | | Find an endpoint or public symbol | API mapping · Symbol index | | Copy a runnable SDK example | Bounded pagination · Publish CI results · Case-field readiness | | Wait for a new custom case field | Case-field readiness | | Install the bundled agent skill | Skill installation | | Understand or contribute to the implementation | Architecture · Contributing · Agent instructions | | Upgrade or publish a release | Changelog · Release guide | | Report a vulnerability | Security policy | | Browse every document | Documentation index |

The client supports TestRail 10.7.0 (Default 1021), including API additions from versions 10.4 through 10.7. The compatibility audit records endpoint coverage, upstream documentation discrepancies, and known gaps against TestRail 10.8 through 10.10.

Sections that moved

Earlier releases documented these topics in this file. Links to the earlier README sections open this table.

| Earlier README section | Current location | | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Repository verification | Verification checks | | Configuration | SDK configuration | | Operation settlement tracking | SDK lifecycle | | Cache isolation and memory | Caching and retries | | Report execution | Caching and retries | | SSRF protection and private hosts | Private servers | | Custom DNS resolvers | Custom DNS resolvers | | Proxies and custom certificate authorities | Proxies and custom certificate authorities | | Pagination | SDK pagination · CLI pagination | | Advisory response validation | Response validation | | Error handling | Error handling | | CLI diagnostic files | Diagnostic files | | Links | Documentation |

License

MIT. If this package saves you time, you can buy me a coffee.