Repository
Current version released
4 years ago
Versions
- v3.0.2Latest
- v3.0.1
- v3.0.0
- v2.19.0
- v2.18.0
- v2.17.0
- v2.16.1
- v2.16.0
- v2.15.17
- v2.15.16
- v2.15.15
- v2.15.14
- v2.15.13
- v2.15.12
- v2.15.11
- v2.15.10
- v2.15.9
- v2.15.8
- v2.15.7
- v2.15.6
- v2.15.5
- v2.15.4
- v2.15.3
- v2.15.2
- v2.15.1
- v2.15.0
- v2.14.0
- v2.13.0
- v2.12.0
- v2.11.0
- v2.10.4
- v2.10.3
- v2.10.2
- v2.10.1
- v2.10.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.3
- v2.6.2
- v2.6.1
- v2.6.0
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.0
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.8.0
- v1.7.3
JavaScript / TypeScript JIRA API Client
A JavaScript / TypeScript wrapper for the JIRA REST API
Installation
Install with the npm:
npm install jira.js
Install with the yarn:
yarn add jira.js
Examples
Create the JIRA client
import { Client } from "jira.js";
// Initialize
const client = new Client({
host: "https://jira.somehost.com"
});
Working with API (How to get a list of all projects, for example)
// Callbacks
client.projects.getAllProjects({}, (err, data) => {
if (err) {
throw err;
}
console.log(data);
});
// ES5/ES6
client.projects
.getAllProjects()
.then(projects => console.log(projects))
.catch(error => console.log(error));
// ES7
async function getProjects() {
const projects = await client.projects.getAllProjects();
console.log(projects);
return projects;
}
Authorization
Basic authorization
With API token
const client = new Client({
host: "https://jira.somehost.com",
authentication: {
basic: {
username: "MyUsername",
apiToken: "API_Token"
}
}
});
With password
const client = new Client({
host: "https://jira.somehost.com",
authentication: {
basic: {
username: "MyUsername",
password: "MyPassword"
}
}
});
JWT authentication
const client = new Client({
host: 'https://jira.somehost.com',
authentication: {
jwt: {
iss: 'id',
secret: 'secret key'
}
}
});
OAuth1.0 authentication
const client = new Client({
host: "https://jira.somehost.com",
authentication: {
oauth1: {
consumerKey: "your consumer key",
consumerSecret: "-----BEGIN RSA PRIVATE KEY-----\n" + "some private key\n" + "-----END RSA PRIVATE KEY-----",
accessToken: "your access token",
tokenSecret: "your token secret"
}
}
});
OAuth2.0 authentication
const client = new Client({
host: "https://jira.somehost.com",
authentication: {
accessToken: "my access token"
}
});
Base request config
If you want to add headers, timeout, withCredentials or other data for each of the requests that will be called, then pass them to baseRequestConfig.
Full list of properties for baseRequestConfig you can find here: https://github.com/axios/axios#request-config
import { Client } from "jira.js";
const client = new Client({
host: 'https://jira.somehost.com',
baseRequestConfig: {
timeout: 20000,
headers: {
'Content-Type': 'application/json',
},
timeoutErrorMessage: 'Error message',
withCredentials: false,
responseType: 'arraybuffer',
maxContentLength: 100,
// and others properties
},
});
Set middleware for Jira’s responses and errors
import { Client } from "jira.js";
const client = new Client({
host: "https://jira.somehost.com",
middlewares: {
onError: (error) => {
console.error(error);
throw error;
},
onResponse: (data) => {
console.log(data);
return data;
}
}
});
Documentation
Library based on Jira API v2 and Jira Agile API
Can’t find what you need in the readme? Check out our documentation here: https://mrrefactoring.github.io/jira.js/
Contributors
MrRefactoring | jayree | Swapnull | violine1101 |
Road map
- Response models (Check 2.0 version PR)
- Method names reducing (Check 2.0 version PR)
Latest version changelog
1.8.0
- Authentication: Added OAuth 1.0 authentication method
- CI: Migrated from
Travis CI
toGithub CI