bitbucket-data-center-client
v1.0.14
Published
TypeScript client library for Bitbucket Server/Data Center REST API
Maintainers
Readme
Bitbucket Data Center Client
TypeScript client for Bitbucket Server/Data Center REST API.
Installation
npm install bitbucket-data-center-clientUsage
import { BitbucketClient } from 'bitbucket-data-center-client';
const client = new BitbucketClient({
baseUrl: 'https://bitbucket.example.com',
token: 'your-personal-access-token',
});
// Get user profile
const user = await client.users.getProfile({ username: 'john.doe' });
// List projects
const projects = await client.projects.list();
// List repositories in a project
const repos = await client.repositories.list({ projectKey: 'PROJ' });
// Browse repository contents
const contents = await client.repositories.browse({
projectKey: 'PROJ',
repositorySlug: 'my-repo',
path: 'src',
});
// Get raw file content
const file = await client.repositories.getRawContent({
projectKey: 'PROJ',
repositorySlug: 'my-repo',
path: 'package.json',
});
// Get pull request details
const pr = await client.pullRequests.get({
projectKey: 'PROJ',
repositorySlug: 'my-repo',
pullRequestId: 123,
});
// Create a pull request
const newPr = await client.pullRequests.create({
projectKey: 'PROJ',
repositorySlug: 'my-repo',
fromBranch: 'feature-branch',
toBranch: 'main',
title: 'Add new feature',
reviewers: ['reviewer1', 'reviewer2'],
});
// Add a comment to a PR
await client.pullRequests.addComment({
projectKey: 'PROJ',
repositorySlug: 'my-repo',
pullRequestId: 123,
text: 'Looks good!',
});
// Approve a PR
await client.pullRequests.updateReviewStatus({
projectKey: 'PROJ',
repositorySlug: 'my-repo',
pullRequestId: 123,
status: 'APPROVED',
});API Structure
| Domain | Methods |
|--------|---------|
| client.users | getProfile, getAll |
| client.projects | list |
| client.repositories | list, get, browse, getRawContent, checkPermissions |
| client.pullRequests | getInbox, getDashboard, get, create, getChanges, getDiff, getFileDiff, getActivities, addComment, deleteComment, updateReviewStatus, addReaction, removeReaction, getRequiredReviewers |
Authentication
Generate a Personal Access Token in Bitbucket: Profile > Manage account > Personal access tokens
export BITBUCKET_URL=https://bitbucket.example.com
export BITBUCKET_TOKEN=your-personal-access-tokenRequirements
- Node.js >= 18.0.0
- Bitbucket Server/Data Center 7.0+
License
MIT
