Registry / devops / bitbucket-srv-rest

bitbucket-srv-rest

JSON →
library2.3.0jsnpmunverified

A Node.js REST client for Atlassian Bitbucket Server (formerly Stash). Current stable version is 2.3.0. The library provides programmatic access to Bitbucket Server's REST API, including operations on projects, repositories, pull requests, and users. It uses Promises for asynchronous requests and is designed for Node.js environments. Key differentiators: it is a dedicated client library specifically for Bitbucket Server, not for Bitbucket Cloud, and it abstracts authentication and request handling.

npm install bitbucket-srv-rest
INSTALL
IMPORT
SIG · BITBUCKET-SRV-REST
B
bitbucket-srv-rest
devopsjavascriptv2.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BitbucketClient
import { BitbucketClient } from 'bitbucket-srv-rest';
const BitbucketClient = require('bitbucket-srv-rest');
The library is ESM-only since v2. Default export is not available; use named import for BitbucketClient.
ProjectAPI
import { ProjectAPI } from 'bitbucket-srv-rest';
import ProjectAPI from 'bitbucket-srv-rest';
All API classes are named exports; there is no default export.
RepositoryAPI
import { RepositoryAPI } from 'bitbucket-srv-rest';
const { RepositoryAPI } = require('bitbucket-srv-rest');
CommonJS require is not supported; use ESM imports.

Creates a BitbucketClient instance with basic auth and lists all projects.

import { BitbucketClient } from 'bitbucket-srv-rest'; const client = new BitbucketClient({ baseUrl: 'https://your-bitbucket-server.com', username: process.env.BITBUCKET_USER ?? 'admin', password: process.env.BITBUCKET_PASSWORD ?? 'password' }); async function getProjects() { try { const projects = await client.project.list(); console.log(projects); } catch (error) { console.error('Error fetching projects:', error); } } getProjects();
Debug
Known issues
breakingVersion 2.x dropped support for callbacks; all API methods now return Promises.
fix
Update your code to use async/await or .then() instead of callbacks.
affects: >=2.0.0 <3.0.0
deprecatedConstructor option 'password' is deprecated; use 'token' or 'basicAuth' instead.
fix
Replace 'password' with 'token' for personal access tokens or use 'basicAuth' object with username and password.
affects: >=1.5.0 <2.0.0
gotchaThe library expects full baseUrl including protocol; omitting 'https://' will cause connection errors.
fix
Always include 'https://' in baseUrl when connecting to Bitbucket Server.
affects: >=1.0.0
gotchaPagination parameters differ from Bitbucket Server API docs; use limit and start instead of page and size.
fix
When paginating, use client.projects.list({ limit: 25, start: 0 }) instead of page/size.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: client.project.list is not a function
Using an older version (<2.0) where methods were lowercase or not exposed.
fix
Update to v2.3.0 and ensure correct import: import { BitbucketClient } from 'bitbucket-srv-rest';
Error: connect ECONNREFUSED
baseUrl is missing protocol or pointing to a wrong port.
fix
Check baseUrl includes 'https://' and correct host:port.
401 Unauthorized
Invalid username/password or token.
fix
Verify credentials and ensure using correct authentication method (basicAuth or token).
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies
axiosrequiredHTTP client for making REST API requests
lodashrequiredUtility library used for data manipulation
Agent activity
7 hits · last 30 days
node
6
Resources
bitbucket-srv-rest — npm install bitbucket-srv-rest · libregistry