Skip to main content

Get branches

Retrieve all branches from a repository, including the current default branch.
GET /api/branches

Parameters

owner
string
required
The username or organization name that owns the repository
repo
string
required
The repository name

Response

Returns an object containing the list of branches and the current default branch.
branches
array
Array of branch names in the repository
currentBranch
string
The name of the current default branch (typically main or master)

Example request

curl -X GET "https://api.gitflare.dev/api/branches?owner=johndoe&repo=my-project"

Example response

{
  "branches": [
    "main",
    "develop",
    "feature/user-auth",
    "feature/api-integration",
    "hotfix/security-patch"
  ],
  "currentBranch": "main"
}

Usage notes

  • The currentBranch field indicates the repository’s default branch that is checked out when the repository is cloned
  • Branch names are returned as an array of strings, ordered alphabetically
  • This endpoint does not require authentication for public repositories
  • For private repositories, you must be authenticated and have access to the repository

Build docs developers (and LLMs) love