Skip to content

atlassian/node-bitbucket

 
 

Repository files navigation

version:@latest Documentation License

Bitbucket.js

Bitbucket API client for Browser and Node.js

Bitbucket API docs: https://api.bitbucket.org

BITBUCKET CLOUD API CHANGING NOTICE: https://developer.atlassian.com/cloud/bitbucket/bitbucket-api-changes-gdpr
BITBUCKET CLOUD API MIGRATION GUIDE: https://developer.atlassian.com/cloud/bitbucket/bbc-gdpr-api-migration-guide

Installation

via npm:

$ npm install bitbucket --save

via yarn:

$ yarn add bitbucket

Usage

Browser

<script src="https://unpkg.com/bitbucket/dist/bitbucket.min.js"></script>
<script>
  const bitbucket = new Bitbucket()
</script>

Node

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.

const clientOptions = {
  baseUrl: 'https://api.bitbucket.org/2.0',
  headers: {},
  options: {
    timeout: 10
  }
}

const bitbucket = new Bitbucket(clientOptions)

This enables you to use bitbucket with both Bitbucket Cloud and Bitbucket Server.

Authentication

bitbucket.authenticate({
  type: 'basic',
  username: 'username',
  password: 'password'
})

API Methods

async/await

try {
  let { data, headers } = await bitbucket.<namespace>.<api>({ ...params })
} catch (err) {}

Promise

bitbucket.<namespace>
  .<api>({ ...params })
  .then(({ data, headers }) => {})
  .catch(err => {})

Callback

bitbucket.<namespace>.<api>({ ...params }, (err, { data, headers }) => {})

Notes:

  • <namespace> is one of the Namespace Names
  • <api> is one of the API Names

Namespace Names

addon, hook_events, webhooks, repositories, branchrestrictions, commits, commitstatuses, issue_tracker, pullrequests, downloads, source, pipelines, refs, snippets, teams, projects, users, search, user, ssh

API Names

Check API client docs: https://bitbucketjs.netlify.com

Examples
bitbucket.repositories
  .list({ username: 'MunifTanjim' })
  .then(({ data, headers }) => console.log(data.values))
  .catch(err => console.error(err))

Acknowledgement

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.

License

Licensed under the MIT License. Check the LICENSE file for details.

About

BitBucket API client for Browser and Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 95.7%
  • HTML 4.3%