# bitbucket

> Bitbucket API client for Browser and Node.js

Latest version **2.12.0** (published 2024-05-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install bitbucket
pnpm add bitbucket
yarn add bitbucket
bun add bitbucket
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.12.0 |
| Published | 2024-05-18 |
| First published | 2012-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 496.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 111 |
| Author | MunifTanjim |
| Maintainers | muniftanjim |
| Keywords | bitbucket, bitbucket-api, api-client, api, rest |

## Links

- npm: https://www.npmjs.com/package/bitbucket
- Repository: https://github.com/MunifTanjim/node-bitbucket
- Homepage: https://github.com/MunifTanjim/node-bitbucket#readme
- Issues: https://github.com/MunifTanjim/node-bitbucket/issues
- npm.io page: https://npm.io/package/bitbucket

## Dependencies (5)

- [deepmerge](https://npm.io/package/deepmerge.md) ^4.2.2
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [url-template](https://npm.io/package/url-template.md) ^2.0.8
- [is-plain-object](https://npm.io/package/is-plain-object.md) ^3.0.0
- [before-after-hook](https://npm.io/package/before-after-hook.md) ^2.1.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 2.12.0 (latest) — 2024-05-18
- 2.0.0-beta.2 (next) — 2019-12-16
- 2.11.0 — 2023-03-08
- 2.10.0 — 2023-02-18
- 2.9.0 — 2022-10-28
- 2.8.0 — 2022-09-09
- 2.7.0 — 2021-11-18
- 2.6.3 — 2021-09-04
- 2.6.2 — 2021-07-02
- 2.6.1 — 2021-04-23
- 2.6.0 — 2021-04-23
- 2.5.1 — 2021-02-26
- 2.5.0 — 2021-02-25
- 2.4.2 — 2020-10-14
- 2.4.1 — 2020-07-20
- … 39 more at https://npm.io/package/bitbucket/versions

## README

[![version:@latest](https://img.shields.io/npm/v/bitbucket.svg?style=for-the-badge)](https://www.npmjs.com/package/bitbucket)
[![Documentation](https://img.shields.io/badge/docs-bitbucket.js-blue.svg?style=for-the-badge)](https://bitbucketjs.netlify.app)
[![License](https://img.shields.io/github/license/MunifTanjim/node-bitbucket.svg?style=for-the-badge)](https://github.com/MunifTanjim/node-bitbucket/blob/master/LICENSE)

# Bitbucket.js

Bitbucket API client for Browser and Node.js

Bitbucket API docs: [https://api.bitbucket.org](https://api.bitbucket.org)

---

**BITBUCKET CLOUD API LATEST UPDATES**: [https://developer.atlassian.com/cloud/bitbucket](https://developer.atlassian.com/cloud/bitbucket)

---

## Installation

via **npm**:

```sh
$ npm install --save bitbucket
```

via **yarn**:

```sh
$ yarn add bitbucket
```

## Usage

### Browser

```html
<script src="https://unpkg.com/bitbucket/lib/index.umd.js"></script>
<script>
  const bitbucket = new Bitbucket()
</script>
```

### Node

```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.<namespace>.<api>({ ...params })
} catch (err) {
  const { message, error, headers, request, status } = err
}
```

**Promise**

```js
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](https://bitbucketjs.netlify.com)

##### Examples

```js
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`](https://github.com/octokit/rest.js/)** and a lot of ideas are taken from there. So, thanks goes to the maintainer [Gregor Martynus](https://github.com/gr2m) and all the [awesome contributors](https://github.com/octokit/rest.js/graphs/contributors) of `octokit/rest.js`.

## License

Licensed under the MIT License. Check the [LICENSE](https://github.com/MunifTanjim/node-bitbucket/blob/master/LICENSE) file for details.

---
_Source: https://npm.io/package/bitbucket · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
