bitbucket-apibitbucket-cloud

Bitbucket API search single file


I want to be able to search/read for a single file without needing the path from bitbucket. Is there a way to do that through the Bitbucket API?


Solution

  • Haven't found an API call for this.
    However there's now a "search code" functionality you may utilize for this, as it's also returns file names. It's not an API call, supported only by browser.
    You'll also have to enable "code searching" for this repository beforehand.

    the call goes like so:
    "https://bitbucket.org/!api/2.0/users/%7Ba2bfcba3-3ec3-4ffe-a6fb-4ce8d138d2dc%7D/search/code?search_query=repo%3A%7B413e33c2-fdb6-4943-b123-82d40bcf4950%7D%20eks&fields=%2Bvalues.file.commit.repository.mainbranch.name"