Jira REST API Client

5.3.1 · active · verified Wed Apr 22

Jira.js is a robust, production-ready JavaScript and TypeScript library designed for seamless interaction with Atlassian Jira Cloud APIs. Currently in version 5.3.1, it provides comprehensive coverage for Jira Cloud REST API v2/v3, Jira Agile Cloud API, and Jira Service Desk Cloud API. The library is actively maintained with regular updates to incorporate new Jira API features and bug fixes, typically releasing patches and minor versions frequently. Its key differentiators include full TypeScript support with exhaustive type definitions, tree-shakability for optimized bundle sizes in browser environments, universal compatibility with Node.js (v20+) and modern browsers, and complete API coverage. It adheres to a modern stack, supporting both ES Modules and CommonJS, and is widely used in production for building Jira integrations, automation tools, webhooks, and custom applications.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize the Jira.js client using basic authentication (email and API token) and then create a new Jira issue within a specified project.

import { Version3Client } from 'jira.js';
import { BasicAuth } from 'jira.js/auth';

const host = process.env.JIRA_HOST ?? 'https://your-domain.atlassian.net';
const email = process.env.JIRA_EMAIL ?? 'your-email@example.com';
const apiToken = process.env.JIRA_API_TOKEN ?? 'YOUR_JIRA_API_TOKEN';

const client = new Version3Client({
  host,
  authentication: new BasicAuth({ email, apiToken }),
});

async function createJiraIssue() {
  try {
    const issue = await client.issues.createIssue({
      fields: {
        project: {
          key: 'YOURPROJECTKEY', // e.g., 'TEST'
        },
        summary: 'Example issue created by jira.js client',
        issuetype: {
          name: 'Task', // Or 'Bug', 'Story' etc.
        },
        description: {
          type: 'doc',
          version: 1,
          content: [
            {
              type: 'paragraph',
              content: [
                {
                  type: 'text',
                  text: 'This is a test issue created programmatically using jira.js.',
                },
              ],
            },
          ],
        },
        priority: {
          name: 'Medium',
        },
      },
    });
    console.log(`Issue created successfully: ${issue.key} at ${host}/browse/${issue.key}`);
    return issue;
  } catch (error) {
    console.error('Error creating Jira issue:', error);
    if (error.response) {
      console.error('Jira API Response Error:', error.response.status, error.response.data);
    }
    throw error;
  }
}

// To run this example, ensure JIRA_HOST, JIRA_EMAIL, and JIRA_API_TOKEN are set
// in your environment variables or replace the placeholders directly.
// createJiraIssue();

view raw JSON →