Bitbucket API client for Browser and Node.js
npm install bitbucket


Bitbucket API client for Browser and Node.js
Bitbucket API docs: https://api.bitbucket.org
---
BITBUCKET CLOUD API LATEST UPDATES: https://developer.atlassian.com/cloud/bitbucket
---
via npm:
``sh`
$ npm install --save bitbucket
via yarn:
`sh`
$ yarn add bitbucket
`html`
`js
const { Bitbucket } = require('bitbucket')
const bitbucket = new Bitbucket()
`
#### Client Options
You can set the APIs' baseUrl and modify some behaviors (e.g. request timeout etc.) by passing a clientOptions object to the Bitbucket constructor.
`js
const clientOptions = {
baseUrl: 'https://api.bitbucket.org/2.0',
request: {
timeout: 10,
},
}
const bitbucket = new Bitbucket(clientOptions)
`
#### Authentication
Using username and password:
`js
const clientOptions = {
auth: {
username: 'username',
password: 'password',
},
}
const bitbucket = new Bitbucket(clientOptions)
`
Using token:
`js
const clientOptions = {
auth: {
token: 'abcdef123456',
},
}
const bitbucket = new Bitbucket(clientOptions)
`
#### API Methods
async/await
`js`
try {
const { data, headers, status, url } = await bitbucket.
} catch (err) {
const { message, error, headers, request, status } = err
}
Promise
`js`
bitbucket.
.
.then(({ data, headers, status, url }) => {})
.catch(({ message, error, headers, request, status }) => {})
Notes:
- is one of the _Namespace Names_
- is one of the _API Names_
#### Namespace Names
branching_model, branchrestrictions, commits, commitstatuses, deploy, deployments, downloads, hook_events, issue_tracker, pipelines, projects, pullrequests, refs, repositories, search, snippet, snippets, source, ssh, teams, user, users, webhooks
#### API Names
Check API client docs: https://bitbucketjs.netlify.com
##### Examples
`js`
bitbucket.repositories
.listGlobal({})
.then(({ data }) => console.log(data.values))
.catch((err) => console.error(err))
This API client is heavily inspired by the octokit/rest.js and a lot of ideas are taken from there. So, thanks goes to the maintainer Gregor Martynus and all the awesome contributors of octokit/rest.js`.
Licensed under the MIT License. Check the LICENSE file for details.