API 2.0 Find files in a branch

StuMid December 16, 2020

Hey all,

Using the API and running this query for example...


returns only myfile.json if it exists in the Master branch of the "myrepo" repo. I can't find any information on how to search within another branch.

How can I alter this search to search either a specific branch or the entire repo?


1 answer

0 votes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 17, 2020

@StuMid the code search API only indexes the main branch so you're correct that you can only use this API with that branch to search file contents.

That said, you can use the src API to fetch files from any branch given that you know the filename.


You can use a branch name where it says "commit" but there is an annoying limitation that the branch name cannot contain a slash. If the branch name contains a slash you'd have to take a 2 step approach and first look up the commit of the branch using the branch API.

Adolfo Perez Solis March 9, 2023

Reading the documentation seems like you also need to know the path in addition to the filename when using the src API you suggested isn't it? In 2023 isn't still an easy way to search for files in a given branch? Without knowing the full path of the file

Like # people like this

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events