REST API: List all files in repo (like git ls-files) (BB-9449)

Issue #8316 open
Aslak Hellesøy
created an issue

There is a "manifest" REST API endpoint for this that is undocumented and seemingly broken. I found it via the apigee browser:

curl https://bitbucket.org/api/1.0/repositories/aslakhellesoy/pygments-main/manifest/a32d7988c3695e0b0a41cf764afaa9e701a858e7

(The apigee API browser suggests a trailing slash, which didn't work).

Anyway, this will only list the files at the root of the repository. I don't know if it's possible to make it behave recursively.

Is there another way to list all files in a repo (for a given revision)? We'd very much like to support Bitbucket in https://cucumber.pro, but we need this functionality to do so.

Comments (13)

  1. Jonathan Mooring staff

    Hi Aslak,

    Thanks for reaching out regarding possible integrations with Cucumber Pro. The manifest endpoint is something of a relic from the past and, as you noted, is not particularly useful.

    We're actively developing our v2 API, with plans to add better source browsing endpoints. While this work is on our roadmap, we don't have a hard release date for it at this time.

    In the meantime, I can point you to an internal endpoint that we use with our quick file search feature (press f at any time while browsing a repo to jump to a particular file). This endpoint is unsupported and is subject to change or deletion at any point. With that in mind, the URL format is as follows:

    https://bitbucket.org/!api/1.0/repositories/atlassian/morec/directory/

    Hope this helps,
    Jon

  2. Aslak Hellesøy reporter

    Thanks a lot Jon!

    I'll try out the internal API. We're actually using another part of it already to save a file - discovered it by editing a file via the web interface :-)

    Looking forward to trying out the 2.0 API when it comes.

  3. Aslak Hellesøy reporter

    Jon, is there a way to specify a revision or branch? It looks to me like this will always give you the head of the default (master) branch.

    History is a central concept for us, so we'd like to see what files existed in the past for a particular revision if possible.

  4. Aslak Hellesøy reporter

    One more question. The returned document has two properties:

    limit: 10000,
    isLastPage: true
    

    I assume this means that the document will never contain more than 10000 files, and if there are more files in the repo, isLastPage will be false.

    My question is - how do I find out where to get the next page? Will there be some header or extra document property to tell me this?

    Thanks! Aslak

  5. Llie

    And the date of the revision of the blob please. I used to simply scrape the HTML of my src/tip page, but with the new dynamically generated HTML this no longer works.

  6. Log in to comment