Bitbucket Data Center API Client
    Preparing search index...

    Class PullRequestResource

    Represents a Bitbucket pull request resource with chainable async methods.

    Implements PromiseLike<BitbucketPullRequest> so it can be awaited directly to fetch the pull request info, while also exposing sub-resource methods.

    // Await directly to get pull request info
    const pr = await bbClient.project('PROJ').repo('my-repo').pullRequest(42);

    // Get activities
    const activities = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).activities();

    // Get tasks
    const tasks = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).tasks();

    // Get commits
    const commits = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).commits();

    // Get changes
    const changes = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).changes();

    // Get reports
    const reports = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).reports();

    // Get build summaries
    const builds = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).buildSummaries();

    // Get linked Jira issues
    const issues = await bbClient.project('PROJ').repo('my-repo').pullRequest(42).issues();

    Implements

    Index

    Methods

    • Approves the pull request on behalf of a participant.

      PUT /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/participants/{userSlug}

      Parameters

      • userSlug: string

        Slug of the user approving (typically the authenticated user)

      Returns Promise<BitbucketParticipant>

      The updated participant

    • Fetches the aggregated build summaries for this pull request.

      Returns a map of commit hash → build counts per state (successful, failed, inProgress, cancelled, unknown).

      The official API exposes build statistics per commit, so this method first fetches the pull request commits (up to 100) and then requests their build statistics in a single batch call (two requests). Commits without any associated builds are not present in the response.

      POST /rest/build-status/latest/commits/stats

      Returns Promise<BitbucketBuildSummaries>

      A record keyed by commit SHA with aggregated build counts

    • Cancels a pending auto-merge request.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/auto-merge

      Returns Promise<void>

    • Deletes a comment.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/comments/{commentId}

      Parameters

      • commentId: number

        The comment id

      • version: number

        Must match the comment's current version

      Returns Promise<void>

    • Deletes a task.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/blocker-comments/{commentId}

      Parameters

      • taskId: number

        The task's comment id

      • version: number

        Must match the task's current version

      Returns Promise<void>

    • Fetches the diff for this pull request.

      GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/diff/{path}

      The path param (the file to diff) is optional: when omitted, the diff for the whole pull request is returned. srcPath is sent as a query parameter and identifies the previous path of a copied, moved or renamed file.

      Parameters

      • Optionalparams: DiffParams

        Optional: path, contextLines, srcPath, whitespace

      Returns Promise<BitbucketDiff>

      The diff object

    • Discards the authenticated user's file-review progress on this pull request.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/review

      Returns Promise<void>

    • Fetches this pull request as a git format-patch-compatible patch file.

      GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}.patch

      Returns Promise<string>

      The raw patch as plain text

    • Fetches the raw unified diff for this pull request, in git diff format.

      GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}.diff

      Returns Promise<string>

      The raw diff as plain text

    • Reacts to a comment with an emoticon (e.g. ':+1:').

      PUT /rest/comment-likes/latest/projects/{key}/repos/{slug}/pull-requests/{id}/comments/{commentId}/reactions/{emoticon}

      Parameters

      • commentId: number

        The comment id

      • emoticon: string

        The emoticon identifier (e.g. '+1', 'heart')

      Returns Promise<void>

      Implemented against the comment-likes API module, which backs the reactions feature in the Bitbucket UI.

    • Removes a reviewer (or any participant) from the pull request entirely.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/participants/{userSlug}

      Parameters

      • userSlug: string

        Slug of the user to remove

      Returns Promise<void>

    • Fetches the Code Insights reports for this pull request.

      Code Insights reports are attached to commits, so this method first fetches the pull request to resolve the latest commit of its source branch and then queries the official Code Insights API for that commit (two requests).

      GET /rest/insights/latest/projects/{key}/repos/{slug}/commits/{commitId}/reports

      Parameters

      Returns Promise<PagedResponse<BitbucketReport>>

      A paged response of Code Insights reports for the latest source commit

    • Fetches the tasks (review to-do items) for this pull request.

      Since Bitbucket 7.2 tasks are modelled as blocker comments (comments with severity: 'BLOCKER') and the legacy /tasks endpoint was removed, so this method queries the blocker-comments endpoint. Tasks can be OPEN or RESOLVED.

      GET /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/blocker-comments

      Parameters

      • Optionalparams: TasksParams

        Optional filters: limit, start, states

      Returns Promise<PagedResponse<BitbucketPullRequestTask>>

      A paged response of pull request tasks (blocker comments)

    • Withdraws a participant's approval, without removing them as a reviewer.

      PUT /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/participants/{userSlug}

      Parameters

      • userSlug: string

        Slug of the user withdrawing their approval

      Returns Promise<BitbucketParticipant>

      The updated participant

    • Removes a reaction from a comment.

      DELETE /rest/comment-likes/latest/projects/{key}/repos/{slug}/pull-requests/{id}/comments/{commentId}/reactions/{emoticon}

      Parameters

      • commentId: number

        The comment id

      • emoticon: string

        The emoticon identifier (e.g. '+1', 'heart')

      Returns Promise<void>

    • Removes the authenticated user as a watcher of this pull request.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/watch

      Returns Promise<void>

    • Adds the authenticated user as a watcher of this pull request.

      POST /rest/api/latest/projects/{key}/repos/{slug}/pull-requests/{id}/watch

      Returns Promise<void>