Represents a Bitbucket repository resource with chainable async methods.

Implements PromiseLike<BitbucketRepository> so it can be awaited directly to fetch repository info, while also exposing sub-resource methods.

// Await directly to get repository info
const repo = await bbClient.project('PROJ').repo('my-repo');

// Get pull requests
const prs = await bbClient.project('PROJ').repo('my-repo').pullRequests({ state: 'OPEN' });

// Navigate into a specific pull request
const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();

// Get commits
const commits = await bbClient.project('PROJ').repo('my-repo').commits({ limit: 10 });

Implements

Methods

  • Browses the contents of a directory or file in this repository.

    GET /rest/api/latest/projects/{key}/repos/{slug}/browse/{srcPath}

    Parameters

    • OptionalsrcPath: string

      Path to browse (e.g., 'src' or 'src/index.ts'). Omit to browse the root.

    • Optionalparams: BrowseParams

      Optional: at (branch/tag/commit), type, blame, noContent, limit, start

    Returns Promise<BitbucketBrowseResponse>

    The browse response with path info and children

  • Returns a CommitResource for a given commit SHA, providing access to commit data and sub-resources (changes, diff).

    The returned resource can be awaited directly to fetch commit info, or chained to access nested resources.

    Parameters

    • commitId: string

      The commit SHA (e.g., 'abc123def456')

    Returns CommitResource

    A chainable commit resource

    const commit  = await bbClient.project('PROJ').repo('my-repo').commit('abc123');
    const changes = await bbClient.project('PROJ').repo('my-repo').commit('abc123').changes();
    const diff = await bbClient.project('PROJ').repo('my-repo').commit('abc123').diff();
  • Fetches the raw content of a file in this repository.

    GET /rest/api/latest/projects/{key}/repos/{slug}/raw/{path}

    Parameters

    • filePath: string

      Path to the file (e.g., 'src/index.ts')

    • Optionalparams: RawFileParams

      Optional: at (branch, tag, or commit SHA)

    Returns Promise<string>

    The raw file content as a string

  • Fetches tags associated with a list of commits.

    POST /rest/api/latest/projects/{key}/repos/{slug}/tags

    Parameters

    • commits: string[]

      Array of commit SHAs to look up tags for

    • Optionaloptions: { apiPath?: string }

      Optional overrides (e.g. apiPath to target a different API version)

    Returns Promise<PagedResponse<BitbucketTag>>

    A paged response of tags