src Resources

Overview

You can use the Bitbucket src resource to browse directories and view files. This is a read-only resource.

GET a list of repo source

Gets a list of the src in a repository. You must supply the following parameters:

Parameter Description
accountname A team or individual account name.
repo_slug The repository's name.
revision A value representing the revision or branch to list.
path The path can be a filename or a directory path. If path ends with / it is interpreted as a directory and returns a list.
https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/src/{revision}/{path}
  Click to view the data returned on success...

GET raw content of an individual file

Gets information about an individual file. This method returns the file's size and contents.  If the file is encoded, this method returns the files encoding; Currently, Bitbucket supports only base64 encoding. You must supply the following parameters:

Parameter Required Description
accountname Yes A team or individual account name.
repo_slug Yes The repository's name.
revision Yes A value representing the revision or branch to list.
path Yes The path can be a filename or a directory path. If path ends with / (forward slash), Bitbucket interprets the path as a directory and returns a list.

Supply a path value whose end node is a file name.

https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/raw/{revision}/{path}
  Click to view the data returned on success...

Was this helpful?

Thanks for your feedback!

8 Archived comments

  1. User avatar

    Anonymous

    any plan to give the ability in a close future to write/update files? This would be an extremely useful feature for the API.

    20 Oct 2012
    1. User avatar

      manthony

      Not that I know of but it is a good suggestion.  You should file an enhancement request for this!

      22 Oct 2012
  2. User avatar

    Anonymous

    Hi,

       Is there a simple way to get a remote raw file with HEAD revision?

       Thanks.

    09 Dec 2012
    1. User avatar

      manthony

      The default (hg) or master (git) revision should give you the raw HEAD revision.  

      https://api.bitbucket.org/1.0/repositories/{accountname}/{repo_slug}/raw/{revision}/{path}
      10 Dec 2012
  3. User avatar

    Dillon

    Is there a way to acquire the source of a branch with a slash in it? E.g: test/123. My attempts leave me with a 404 Not Found with the slash and when i try to convert it to it's escapable equivalent: %2F. This doesn't seem to be an issue via the Webpage but the API interface seems to be broken unless there's something I'm missing.

    03 Apr 2013
  4. User avatar

    Anonymous

    It seems like HEAD is not allowed. Any reason for that?

    curl -i -X HEAD https://api.bitbucket.org/1.0/repositories/....

    HTTP/1.1 405 METHOD NOT ALLOWED

    06 Sep 2013
  5. User avatar

    DJ Marcaida

    GET raw content of an individual file is the same resource as repository Resource 1.0#GETtherawsource

    These resources, as well as GET a list of repo source, seem redundant.

    12 Mar 2015
  6. User avatar

    Noris Nyamekye

    Is there a way of uploading an file via the api?

    14 Jul 2015
Powered by Confluence and Scroll Viewport