Skip to end of metadata
Go to start of metadata

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:

ParameterDescription
accountnameA team or individual account name.
repo_slugThe repository's name.
revisionA value representing the revision or branch to list.
pathThe 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:

ParameterRequiredDescription
accountnameYesA team or individual account name.
repo_slugYesThe repository's name.
revisionYesA value representing the revision or branch to list.
pathYesThe 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...

 

 

 

 

 

6 Comments

  1. 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.

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

  2. Anonymous

    Hi,

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

       Thanks.

    1. 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}
  3. 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.

  4. 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