Addon
Branch restrictions
Branching model
Commit statuses
Commits
Deployments
Downloads
Issue tracker
Pipelines
Projects
Pullrequests
Refs
Reports
Repositories
Snippets
Source
Ssh
Users
Webhooks
Workspaces
Other operations

Rate this page:

Source

Browse the source code in the repository and create new commits by uploading.

List commits that modified a file

GET /2.0/repositories/{workspace}/{repo_slug}/filehistory/{commit}/{path}

Returns a paginated list of commits that modified the specified file.

Commits are returned in reverse chronological order. This is roughly equivalent to the following commands:

1
2
$ git log --follow --date-order <sha> <path>

By default, Bitbucket will follow renames and the path name in the returned entries reflects that. This can be turned off using the ?renames=false query parameter.

Results are returned in descending chronological order by default, and like most endpoints you can filter and sort the response to only provide exactly the data you want.

For example, if you wanted to find commits made before 2011-05-18 against a file named README.rst, but you only wanted the path and date, your query would look like this:

1
2
$ curl 'https://api.bitbucket.org/2.0/repositories/evzijst/dogslow/filehistory/master/README.rst'\
  '?fields=values.next,values.path,values.commit.date&q=commit.date<=2011-05-18'
{
  "values": [
    {
      "commit": {
        "date": "2011-05-17T07:32:09+00:00"
      },
      "path": "README.rst"
    },
    {
      "commit": {
        "date": "2011-05-16T06:33:28+00:00"
      },
      "path": "README.txt"
    },
    {
      "commit": {
        "date": "2011-05-16T06:15:39+00:00"
      },
      "path": "README.txt"
    }
  ]
}

In the response you can see that the file was renamed to README.rst by the commit made on 2011-05-16, and was previously named README.txt.

repository

Request

Path parameters
commit Required

string

The commit's SHA1.

path Required

string

Path to the file.

repo_slug Required

string

This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: {repository UUID}.

workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: {workspace UUID}.

Query parameters
renames

string

When true, Bitbucket will follow the history of the file across renames (this is the default behavior). This can be turned off by specifying false.

q

string

Query string to narrow down the response as per filtering and sorting.

sort

string

Name of a response property sort the result by as per filtering and sorting.

Example

1
2
3
4
curl --request GET \
  --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/filehistory/{commit}/{path}' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Accept: application/json'

Responses

A paginated list of commits that modified the specified file

Content typeValue
application/json

Paginated Files

Get the root directory of the main branch

GET /2.0/repositories/{workspace}/{repo_slug}/src

This endpoint redirects the client to the directory listing of the root directory on the main branch.

This is equivalent to directly hitting /2.0/repositories/{username}/{repo_slug}/src/{commit}/{path} without having to know the name or SHA1 of the repo's main branch.

To create new commits, POST to this endpoint

repository

Request

Path parameters
repo_slug Required

string

This can either be the repository slug or the UUID of the repository, surrounded by curly-braces, for example: {repository UUID}.

workspace Required

string

This can either be the workspace ID (slug) or the workspace UUID surrounded by curly-braces, for example: {workspace UUID}.

Query parameters
format

string

Instead of returning the file's contents, return the (json) meta data for it.

Valid values: meta

Example

1
2
3
4
curl --request GET \
  --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug}/src' \
  --header 'Authorization: Bearer <access_token>' \
  --header 'Accept: application/json'

Responses