3.0.5 • Published 1 month ago

jira.js v3.0.5

Weekly downloads
2,615
License
MIT
Repository
github
Last release
1 month ago

JavaScript / TypeScript library for Node.JS and browsers to easily interact with Atlassian Jira API

About

jira.js is a powerful Node.JS / Browser module that allows you to interact with the Jira Cloud API, Jira Agile Cloud API, Jira ServiceDesk Cloud API very easily.

Usability, consistency, and performance are key focuses of jira.js, and it also has nearly 100% coverage of the Jira API. It receives new Jira features shortly after they arrive in the API.

Table of contents

Installation

Node.js 18.0.0 or newer is required.

Install with the npm:

npm install jira.js

Install with the yarn:

yarn add jira.js

Documentation

You can find the documentation here.

Usage

Authentication

There are several types of authentication to gain access to the Jira API. Let's take a look at a few of them below

Basic authentication

Basic authentication allows you to log in with credentials. You can use username and password, but this login method is not supported in the online version and most standalone versions, so it's better to release API Token, read how to do it here, and use it together with email.

Username and password example:

import { Version3Client } from 'jira.js';

const client = new Version3Client({
  host: 'https://your-domain.atlassian.net',
  authentication: {
    basic: {
      username: 'YOUR_USERNAME',
      password: 'YOUR_PASSWORD',
    },
  },
});

Email and API Token example:

import { Version3Client } from 'jira.js';

const client = new Version3Client({
  host: 'https://your-domain.atlassian.net',
  authentication: {
    basic: {
      email: 'YOUR@EMAIL.ORG',
      apiToken: 'YOUR_API_TOKEN',
    },
  },
});
OAuth 2.0

Only the authorization token is currently supported. To release it, you need to read the documentation and write your own code to get the token.

Example of usage

import { Version3Client } from 'jira.js';

const client = new Version3Client({
  host: 'https://your-domain.atlassian.net',
  authentication: {
    oauth2: {
      accessToken: 'YOUR_ACCESS_TOKEN',
    },
  },
});
Personal access token
import { Version3Client } from 'jira.js';

const client = new Version3Client({
  host: 'https://your-domain.atlassian.net',
  authentication: {
    personalAccessToken: 'secrectPAT',
  },
});

Example and using algorithm

  1. Example

You can find out examples project here or perform the following actions:

  • Change the host, email and apiToken to your data
  • Run script
import { Version3Client } from 'jira.js';

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

async function main() {
  const projects = await client.projects.getAllProjects();

  if (projects.length) {
    const project = projects[0];

    const { id } = await client.issues.createIssue({
      fields: {
        summary: 'My first issue',
        issuetype: {
          name: 'Task'
        },
        project: {
          key: project.key,
        },
      }
    });

    const issue = await client.issues.getIssue({ issueIdOrKey: id });

    console.log(`Issue '${issue.fields.summary}' was successfully added to '${project.name}' project.`);
  } else {
    const myself = await client.myself.getCurrentUser();

    const { id } = await client.projects.createProject({
      key: 'PROJECT',
      name: "My Project",
      leadAccountId: myself.accountId,
      projectTypeKey: 'software',
    });

    const project = await client.projects.getProject({ projectIdOrKey: id.toString() });

    console.log(`Project '${project.name}' was successfully created.`);
  }
}

main();
  1. The algorithm for using the library:
client.<group>.<methodName>(parametersObject);

Available groups:

The name of the methods is the name of the endpoint in the group without spaces and in camelCase.

The parameters depend on the specific endpoint. For more information, see here.

Decreasing Webpack bundle size

If you use Webpack and need to reduce the size of the assembly, you can create your client with only the groups you use.

import { BaseClient } from 'jira.js';
import { Board } from 'jira.js/out/agile';
import { Groups } from 'jira.js/out/version2';
import { Issues } from 'jira.js/out/version3';

export class CustomJiraClient extends BaseClient {
  board = new Board(this);
  groups = new Groups(this);
  issues = new Issues(this);
}

Take a look at our other products

  • Confluence.js - confluence.js is a powerful Node.JS / Browser module that allows you to interact with the Confluence API very easily
  • Trello.js - JavaScript / TypeScript library for Node.JS and browsers to easily interact with Atlassian Trello API

License

Distributed under the MIT License. See LICENSE for more information.

3.0.5

1 month ago

3.0.4

2 months ago

3.0.2

4 months ago

3.0.1

5 months ago

3.0.0

6 months ago

2.20.0

7 months ago

2.20.1

7 months ago

2.19.0

11 months ago

2.19.1

10 months ago

2.18.0

1 year ago

2.17.0

1 year ago

2.16.1

1 year ago

2.16.0

1 year ago

2.15.17

1 year ago

2.15.15

1 year ago

2.15.16

1 year ago

2.15.13

1 year ago

2.15.14

1 year ago

2.15.12

1 year ago

2.15.9

2 years ago

2.15.11

2 years ago

2.15.10

2 years ago

2.15.8

2 years ago

2.15.6

2 years ago

2.15.7

2 years ago

2.15.4

2 years ago

2.15.5

2 years ago

2.15.2

2 years ago

2.15.3

2 years ago

2.15.0

2 years ago

2.15.1

2 years ago

2.13.0

2 years ago

2.14.0

2 years ago

2.12.0

2 years ago

2.11.0

2 years ago

2.10.1

2 years ago

2.10.2

2 years ago

2.10.0

2 years ago

2.9.0

2 years ago

2.10.3

2 years ago

2.10.4

2 years ago

2.8.0

2 years ago

2.7.0

3 years ago

2.6.3

3 years ago

2.6.2

3 years ago

2.6.1

3 years ago

2.6.0

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.5.0

3 years ago

2.4.2

3 years ago

2.4.1

3 years ago

2.4.0

3 years ago

2.3.0

3 years ago

2.2.1

3 years ago

2.2.0

3 years ago

2.1.1

3 years ago

2.1.0

3 years ago

2.0.6

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.8.0

3 years ago

1.7.3

3 years ago

1.7.2

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago