Get Branches for a Repository

Xray REST APIs

Products
JFrog Xray
Content Type
REST API

Description: Retrieve all the branches that belong to a specific repository. 

Note: This API endpoint allows you to fetch all Git branches associated with a given repository identified by its repo_id.

Since: Xray version 3.122

Security: A user with READ permissions is required.

Usage: GET /xray/api/v1/git/repositories/{repository_id}/branches

Produces: application/json

Path Parameters

Name

Type

Required/Optional

Description

repository_id

string

Required

The unique identifier of the repository for which you want to retrieve branches

Query Parameters

Name

Type

Required/Optional

Description

page

integer

optional

The page number for pagination. Default: 1

limit

integer

optional

The number of results per page. Default: 50

order_by

string

optional

Sort order by name or last_scanned_date

direction

string

optional

The direction by which to order the results: asc or desc

Response Codes

Name

Description

200

OK

400

Bad request: invalid parameters

401

Unauthorized

403

Forbidden

404

Not found: repository_id doesn't exist

500

Internal error

Response Body

Name

Type

Description

page

integer

The current page number of the result set

llimit

integer

The number of items returned per page

total_count

integer

The total number of branches available for the repository

repository_id

integer

The unique identifier of the repository for which branches are being retrieved

repository_url

string

The URL of the repository

repository_name

string

The name of the repository

branches

srray[branch]

An array of branch objects, each containing details about individual branches

branch

Name

Type

Description

name

string

The name of the branch

last_scanned_date

string

The timestamp of the last scan on this branch, formatted in ISO 8601

last_scanned_commit

string

The hash of the last scanned commit for the branch

scanned_commits_count

integer

The total number of commits scanned for this branch

Successful Response Example

{
  "page": 1,
  "limit": 10,
  "total_count": 1,
  "repository_id": 12,
  "repository_url": "https://git.jfrog.info/projects/XSC/repos/xsc-service",
  "repository_name": "xsc-service",
  "branches": [
    {
      "name": "main",
      "last_scanned_commit": "8ba779e5",
      "last_scanned_date": "2024-08-10T10:13:48Z",
      "scanned_commits_count": 1
    }
  ]
}