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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@qytera/xray-client

v4.0.0

Published

A typesafe HTTP client for the Xray API.

Readme

npm version npm downloads open GitHub issues unaddressed GitHub issues

Node.js Xray Client

This project provides TypeScript clients to users that want to interact with the API of Xray. Supports Xray server and Xray cloud.

[!WARNING] The client is at a very early stage of development and may not cover all Xray interactions. Please refer to the roadmaps for full lists of supported endpoints.


Based on: https://docs.getxray.app/display/XRAY/REST+API

  • v1
    • Tests
      • [x] GET /rest/raven/1.0/api/test
      • [x] GET /rest/raven/1.0/api/settings/teststatuses
      • [x] GET /rest/raven/1.0/api/test/{key}/testruns
      • [x] GET /rest/raven/1.0/api/test/{key}/preconditions
      • [x] GET /rest/raven/1.0/api/test/{key}/testsets
      • [x] GET /rest/raven/1.0/api/test/{key}/testexecutions
      • [x] GET /rest/raven/1.0/api/test/{key}/testplans
      • Test Steps
        • [x] GET /rest/raven/1.0/api/settings/teststepstatuses
        • [x] GET /rest/raven/1.0/api/test/{testKey}/step
        • [x] GET /rest/raven/1.0/api/test/{testKey}/step/{id}
        • [x] PUT /rest/raven/1.0/api/test/{testKey}/step
        • [x] POST /rest/raven/1.0/api/test/{testKey}/step/{id}
        • [x] DELETE /rest/raven/1.0/api/test/{testKey}/step/{id}
        • [x] GET /rest/raven/1.0/api/test/{testKey}/step/{id}/attachment
        • [x] DELETE /rest/raven/1.0/api/test/{testKey}/step/{id}/attachment/{attachmentID}
    • Pre-Conditions
      • [ ] GET /rest/raven/1.0/api/precondition/{preConditionKey}/test
      • [ ] POST /rest/raven/1.0/api/precondition/{preConditionKey}/test
      • [ ] DELETE /rest/raven/1.0/api/precondition/{preConditionKey}/test/{testKey}
    • Test Sets
      • [ ] GET /rest/raven/1.0/api/testset/{testSetKey}/test
      • [ ] POST /rest/raven/1.0/api/testset/{testSetKey}/test
      • [ ] DELETE /rest/raven/1.0/api/testset/{testSetKey}/test/{testKey}
    • Test Plans
      • [x] GET /rest/raven/1.0/api/testplan/{testPlanKey}/test
      • [ ] POST /rest/raven/1.0/api/testplan/{testPlanKey}/test
      • [ ] DELETE /rest/raven/1.0/api/testplan/{testPlanKey}/test/{testKey}
      • [x] GET /rest/raven/1.0/api/testplan/{testPlanKey}/testexecution
      • [ ] POST /rest/raven/1.0/api/testplan/{testPlanKey}/testexecution
      • [ ] DELETE /rest/raven/1.0/api/testplan/{testPlanKey}/testexecution/{testExecKey}
    • Test Executions
      • [x] GET /rest/raven/1.0/api/testexec/{testExecKey}/test
      • [ ] POST /rest/raven/1.0/api/testexec/{testExecKey}/test
      • [ ] DELETE /rest/raven/1.0/api/testexec/{testExecKey}/test/{testKey}
    • Test Runs
      • [x] GET /rest/raven/1.0/api/testrun/{id}/
      • [x] GET /rest/raven/1.0/api/testrun/
      • [x] PUT /rest/raven/1.0/api/testrun/{id}/
      • [ ] GET /rest/raven/1.0/api/testrun/{id}/status
      • [ ] PUT /rest/raven/1.0/api/testrun/{id}/status
      • [ ] GET /rest/raven/1.0/api/testrun/{id}/defect
      • [ ] POST /rest/raven/1.0/api/testrun/{id}/defect
      • [ ] DELETE /rest/raven/1.0/api/testrun/{id}/defect/{issueIdOrKey}
      • [x] GET /rest/raven/1.0/api/testrun/{id}/attachment
      • [x] POST /rest/raven/1.0/api/testrun/{id}/attachment
      • [x] DELETE /rest/raven/1.0/api/testrun/{id}/attachment
      • [x] DELETE /rest/raven/1.0/api/testrun/{id}/attachment/{attachmentid}
      • [ ] GET /rest/raven/1.0/api/testrun/{id}/comment
      • [ ] PUT /rest/raven/1.0/api/testrun/{id}/comment
      • [ ] GET /rest/raven/1.0/api/testrun/{id}/example
      • [ ] GET /rest/raven/1.0/api/testrun/{id}/step
      • [ ] GET /rest/raven/1.0/api/testrun/{id}/assignee
      • [ ] PUT /rest/raven/1.0/api/testrun/{id}/assignee
      • Test Examples
        • [ ] GET /rest/raven/1.0/api/testrun/{id}/example/{exampleIndex}
        • [ ] PUT /rest/raven/1.0/api/testrun/{id}/example/{exampleIndex}
      • Test Step Results
        • [ ] GET /rest/raven/1.0/api/testrun/{id}/step/{stepResultId}/
        • [ ] PUT /rest/raven/1.0/api/testrun/{id}/step/{stepResultId}/
        • [ ] GET /rest/raven/1.0/api/testrun/{id}/step/{stepResultId}/status
        • [ ] PUT /rest/raven/1.0/api/testrun/{id}/step/{stepResultId}/status
        • [ ] GET /rest/raven/1.0/api/testrun/{id}/step/{stepResultId}/attachment
        • [ ] POST /rest/raven/1.0/api/testrun/{id}/step/{stepResultId}/attachment
        • [ ] DELETE /rest/raven/1.0/api/testrun/{id}/step/{stepResultId}/attachment
        • [ ] DELETE /rest/raven/1.0/api/testrun/{id}/step/{stepResultId}/attachment/{attachmentid}
    • Test Repository
      • [ ] GET /rest/raven/1.0/api/testrepository/{projectKey}/folders
      • [ ] GET /rest/raven/1.0/api/testrepository/{projectKey}/folders/{folderId}/tests
      • [ ] PUT /rest/raven/1.0/api/testrepository/{projectKey}/folders/{folderId}/tests
      • [ ] GET /rest/raven/1.0/api/testrepository/{projectKey}/folders/{folderId}
      • [ ] POST /rest/raven/1.0/api/testrepository/{projectKey}/folders/{folderId}
      • [ ] PUT /rest/raven/1.0/api/testrepository/{projectKey}/folders/{folderId}
      • [ ] DELETE /rest/raven/1.0/api/testrepository/{projectKey}/folders/{folderId}
    • Import Execution Results
      • [x] POST /rest/raven/1.0/api/import/execution
      • [x] POST /rest/raven/1.0/api/import/execution/multipart
      • [ ] POST /rest/raven/1.0/api/import/execution/cucumber
      • [ ] POST /rest/raven/1.0/api/import/execution/cucumber/multipart
      • [ ] POST /rest/raven/1.0/api/import/execution/behave
      • [ ] POST /rest/raven/1.0/api/import/execution/behave/multipart
      • [ ] POST /rest/raven/1.0/api/import/execution/junit
      • [ ] POST /rest/raven/1.0/api/import/execution/junit/multipart
      • [ ] POST /rest/raven/1.0/api/import/execution/testng
      • [ ] POST /rest/raven/1.0/api/import/execution/testng/multipart
      • [ ] POST /rest/raven/1.0/api/import/execution/nunit
      • [ ] POST /rest/raven/1.0/api/import/execution/nunit/multipart
      • [ ] POST /rest/raven/1.0/api/import/execution/xunit
      • [ ] POST /rest/raven/1.0/api/import/execution/xunit/multipart
      • [ ] POST /rest/raven/1.0/api/import/execution/robot
      • [ ] POST /rest/raven/1.0/api/import/execution/robot/multipart
      • [ ] POST /rest/raven/1.0/api/import/execution/bundle
    • Export Execution Results
      • [ ] GET /rest/raven/1.0/api/testruns
      • [ ] GET /rest/raven/1.0/api/execution/result (deprecated)
    • Importing Cucumber Tests
      • [ ] POST /rest/raven/1.0/api/import/feature
    • Exporting Cucumber Tests
      • [ ] GET /rest/raven/1.0/api/export/test
    • Settings
      • [ ] GET /rest/raven/1.0/api/settings/teststatuses
      • [ ] GET /rest/raven/1.0/api/settings/teststepstatuses
  • v2
    • Test Step
      • [x] GET /rest/raven/2.0/api/test/{testKey}/steps
      • [x] POST /rest/raven/2.0/api/test/{testKey}/steps
      • [x] GET /rest/raven/2.0/api/test/{testKey}/steps/{stepId}
      • [x] PUT /rest/raven/2.0/api/test/{testKey}/steps/{stepId}
      • [x] DELETE /rest/raven/2.0/api/test/{testKey}/steps/{stepId}
      • [x] GET /rest/raven/2.0/api/test/{testKey}/steps/{stepId}/attachments
      • [x] DELETE /rest/raven/2.0/api/test/{testKey}/steps/{stepId}/attachment/{attachmentId}
    • Test Run
      • [x] GET /rest/raven/2.0/api/testrun
      • [x] GET /rest/raven/2.0/api/testrun/{id}
      • [x] PUT /rest/raven/2.0/api/testrun/{id}
      • [ ] GET /rest/raven/2.0/api/testrun/{id}/customfield/{customFieldId}
      • [ ] PUT /rest/raven/2.0/api/testrun/{id}/customfield/{customFieldId}
      • [ ] GET /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}
      • [ ] PUT /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}
      • [ ] GET /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}/step
      • [ ] GET /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}/step/{stepResultId}
      • [ ] PUT /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}/step/{stepResultId}
      • [ ] GET /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}/step/{stepResultId}/status
      • [ ] PUT /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}/step/{stepResultId}/status
      • [ ] GET /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}/step/{stepResultId}/attachment
      • [ ] POST /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}/step/{stepResultId}/attachment
      • [ ] DELETE /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}/step/{stepResultId}/attachment
      • [ ] DELETE /rest/raven/2.0/api/testrun/{id}/iteration/{iterationId}/step/{stepResultId}/attachment/{attachmentId}
      • [ ] GET /testruns
    • Test Run Status
      • [ ] PUT /rest/raven/2.0/api/testrunstatus/reset
    • Requirement Status
      • [ ] PUT /rest/raven/2.0/api/requirementstatus/reset
    • Project
      • [ ] GET /rest/raven/2.0/api/project/{id}/settings/customfields/testruns
      • [ ] GET /rest/raven/2.0/api/project/{id}/settings/customfields/teststeps
    • External Apps
      • [ ] GET /rest/raven/2.0/api/xraylicense
    • Import
      • [x] POST /rest/raven/2.0/api/import/execution
      • [x] POST /rest/raven/2.0/api/import/execution/multipart
    • Dataset
      • [x] GET /rest/raven/2.0/api/dataset/export
      • [x] POST /rest/raven/2.0/api/dataset/import
    • Test Repository
      • [ ] GET /rest/raven/2.0/api/testrepository/{projectKey}/folders/{folderId}

Based on: https://docs.getxray.app/display/XRAYCLOUD/REST+API

Installation

Xray Server

npm install @qytera/xray-client

Xray Cloud

If you don't intend to use the GraphQL endpoints:

npm install @qytera/xray-client

With GraphQL support:

npm install @qytera/xray-client graphql graphql-tag

Usage

Simply create a client instance for your Xray setup and start using the fully typed endpoints available.

Xray Server

import { XrayClientServer } from "@qytera/xray-client";

// PAT authentication.
export const serverClient = new XrayClientServer({
  credentials: {
    token: "jira-token",
  },
  url: "https://jira.company.com",
});

// Basic authentication.
export const serverClient = new XrayClientServer({
  credentials: {
    username: "jira-username",
    password: "jira-password",
  },
  url: "https://jira.company.com",
});

const csvData = await serverClient.dataset.export({ testIssueKey: "PRJ-123" });
const testRun = await serverClient.testRun.getTestRun({
  testExecIssueKey: "PRJ-456",
  testIssueKey: "PRJ-123",
});
// ... other endpoints

Xray Cloud

import { XrayClientCloud } from "@qytera/xray-client";

// Xray cloud authentication.
export const cloudClient = new XrayClientCloud({
  credentials: {
    clientId: "xray-client-id",
    clientSecret: "xray-client-secret",
    path: "/api/v2/authenticate",
  },
  url: "https://xray.cloud.getxray.app",
});

const csvData = await cloudClient.dataset.export({ testIssueKey: "PRJ-123" });
// ... other endpoints

The GraphQL query and mutation endpoints are also available. For example, consider the following getTestRuns query:

{
  getTestRuns(limit: 100, testExecIssueIds: ["XCN-2"]) {
    total
    limit
    start
    results {
      test {
        jira(fields: ["key"])
      }
    }
  }
}

It can easily be mapped to the following code snippet using the library:

const testRuns = await cloudClient.graphql.getTestRuns(
  { limit: 100, testExecIssueIds: ["XCN-2"] },
  (testRunResults) => [
    testRunResults.total,
    testRunResults.limit,
    testRunResults.start,
    testRunResults.results((testRun) => [
      testRun.test((test) => [
        test.jira({ fields: ["key"] })
      ])
    ]),
  ]
);

Version Specification

Xray server and Xray cloud both have versioned API endpoints with slightly different behaviour. By default, the clients access the latest documented version available for each endpoint.

You can switch between versions on a per-request basis:

// Xray server:
const evidence = await serverClient.testRun.evidence.getEvidence("12345"); // 2.0 endpoint
const evidence = await serverClient.testRun.evidence.v1.getEvidence("12345"); // 1.0 endpoint

// Xray cloud:
const attachment = await cloudClient.attachment.addAttachment("my-file.txt"); // v2 endpoint
const attachment = await cloudClient.attachment.v1.addAttachment("my-file.txt"); // v1 endpoint

Custom HTTP Agents

The clients can use custom HTTP agents in the form of custom fetch implementations. The recommended approach is to use undici, which is already included in Node.js but is not exposed.

[!NOTE] Make sure to install the version of undici that comes with the installed version of Node.js to avoid version conflicts and typing issues:

npm install undici@$(node -e "console.log(process.versions.undici)")
import { ProxyAgent, fetch } from "undici";

const proxyAgent = new ProxyAgent({
  token: Buffer.from("username:password").toString("base64"),
  uri: "http://1.2.3.4:8765",
});

const configuration: ClientConfiguration = {
  fetch: (url, init) => {
    return fetch(url, { ...init, dispatcher: proxyAgent });
  },
  credentials: { /* ... */ },
  url: ...
};

Error Handling

Requests may result in HTTP error responses (e.g. 400 Bad Request, 403 Forbidden, 500 Internal Server Error) depending on the request configuration. The clients always throw errors when the actual response status does not match the expected status defined internally for each endpoint.

[!NOTE] Unfortunately, Xray's official documentation is not always precise about error response formats. The error responses also vary between Xray server/cloud and based on the Jira/Xray versions present. It is therefore impossible for the clients to directly model all error responses.

To handle response errors gracefully, use isResponseError to adapt possible outcomes to your Xray environment:

import { isResponseError } from "@qytera/xray-client";

try {
  const data = await client.import.execution.xray(/* ... */);
  // ...
} catch (error: unknown) {
  if (isResponseError(error)) {
    // access request/response data
    console.error("request failed:", error.request.url);
    console.error("request failed:", error.response.json.details);
  } else {
    // ...
  }
}

You can also easily define your own expected response error details and distinguish between them:

import { isResponseError } from "@qytera/xray-client";

try {
  const data = await client.import.execution.xray(/* ... */);
  // ...
} catch (error: unknown) {
  if (isResponseError(error, 400)) {
    console.error("Bad Request:", error.response.text);
  } else if (isResponseError<{ missingPermission: string }>(error, 403)) {
    console.error("Forbidden:", error.response.json.missingPermission);
  } else {
    console.error("Unexpected error:", error);
  }
}

Credits

This project was heavily inspired by jira.js.