Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

bitbucket

MunifTanjim371.7kMIT2.12.0TypeScript support: included

Bitbucket API client for Browser and Node.js

bitbucket, bitbucket-api, api-client, api, rest

readme

version:@latest Documentation License

Bitbucket.js

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


Installation

via npm:

$ npm install --save bitbucket

via yarn:

$ yarn add bitbucket

Usage

Browser

<script src="https://unpkg.com/bitbucket/lib/index.umd.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',
  request: {
    timeout: 10,
  },
}

const bitbucket = new Bitbucket(clientOptions)

Authentication

Using username and password:

const clientOptions = {
  auth: {
    username: 'username',
    password: 'password',
  },
}

const bitbucket = new Bitbucket(clientOptions)

Using token:

const clientOptions = {
  auth: {
    token: 'abcdef123456',
  },
}

const bitbucket = new Bitbucket(clientOptions)

API Methods

async/await

try {
  const { data, headers, status, url } = await bitbucket.<namespace>.<api>({ ...params })
} catch (err) {
  const { message, error, headers, request, status } = err
}

Promise

bitbucket.<namespace>
  .<api>({ ...params })
  .then(({ data, headers, status, url }) => {})
  .catch(({ message, error, headers, request, status }) => {})

Notes:

  • <namespace> is one of the Namespace Names
  • <api> 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
bitbucket.repositories
  .listGlobal({})
  .then(({ data }) => 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.

changelog

Changelog

Unreleased

  • ...

2.12.0 - 2024-05-18

  • Generate from latest API Specification

2.11.0 - 2023-03-08

  • Generate from latest API Specification

2.10.0 - 2023-02-18

  • Generate from latest API Specification

2.9.0 - 2022-10-28

  • Generate from latest API Specification

2.8.0 - 2022-09-09

  • Generate from latest API Specification

2.7.0 - 2021-11-18

  • Generate from latest API Specification

2.6.3 - 2021-09-04

  • Generate from latest API Specification

2.6.2 - 2021-07-02

  • Generate from latest API Specification

2.6.1 - 2021-04-24

  • Remove dependency @node-fetch/btoa-lite

2.6.0 - 2021-04-23

  • Generate from latest API Specification

2.5.1 - 2021-02-26

  • Generate routes for missing item 80

2.5.0 - 2021-02-25

  • Generate from latest API Specification #82

2.4.2 - 2020-10-14

  • Fix endpoint/utils/add-query-parameters

2.4.1 - 2020-07-21

  • Fix endpoint/utils/add-query-parameters

2.4.0 - 2020-07-15

  • Add endpoints for: Workspace
  • Update notice plugin

2.3.0 - 2020-06-29

  • Generate from latest API Specification

2.2.0 - 2020-05-23

  • Add better support for TypeScript types, resolves #61

2.1.0 - 2020-05-02

  • Add endpoints for: PropertyValue, Reports, Annotation

2.0.3 - 2020-02-14

2.0.2 - 2020-02-05

  • Export types: APIEndpoints, Params, Schema #50

2.0.1 - 2020-02-04

  • Fix types #50

2.0.0 - 2020-02-01

  • Version 2 Release