Bitbucket Documentation

Index

Skip to end of metadata
Go to start of metadata

The bitbucket 'changesets' REST resource provides functionality for getting information about changesets in your bitbucket repository.

Overview

This is a read-only resource.

Example, getting a list of changesets:

$ curl https://api.bitbucket.org/1.0/repositories/jespern/django-piston/changesets

{
    "count": 219,
    "start": "tip",
    "limit": 15,
    "changesets": [
        {
            "node": "21a24da68710",
            "files": [
                {
                    "type": "modified",
                    "file": "piston/oauth.py"
                }
            ],
            "author": "jespern",
            "timestamp": "2009-09-08 12:49:43",
            "branch": "default",
            "message": "oauth 1.0a spec ready oauth.py",
            "revision": 204,
            "size": 4166
        },
	...
}

Another example, getting a specific changeset:

$ curl https://api.bitbucket.org/1.0/repositories/jespern/django-piston/changesets/fa57572a9acf

{
    "author": "jespern",
    "branch": "default",
    "files": [
        {
            "file": "piston/handler.py",
            "type": "modified"
        }
    ],
    "message": "warning in case of a model being registered twice under different handlers, configurable via PISTON_IGNORE_DUPE_MODELS",
    "node": "fa57572a9acf",
    "revision": 207,
    "size": 561,
    "timestamp": "2009-09-09 12:55:07"
}

To get more information about the files that are affected by the changeset:

$ curl https://api.bitbucket.org/1.0/repositories/jespern/django-piston/changesets/c9fe89f3ec79/diffstat                                  
[
    {
        "type": "modified", 
        "file": "piston/emitters.py", 
        "diffstat": {
            "removed": 2, 
            "added": 2
        }
    }, 
    {
        "type": "modified", 
        "file": "piston/resource.py", 
        "diffstat": {
            "removed": 10, 
            "added": 6
        }
    }
]

 

 

Getting a List of Changesets

GET /repositories/USERNAME/REPO_SLUG/changesets

Returns a list of changesets for a repository.

Parameters:

  • USERNAME: The owner username.
  • REPO_SLUG: The slug of the repository.

In addition, you can add the following query string parameters:

  • start: The node to begin with. The default is 'tip'.
  • limit: The number of changesets returned. The default is 15.

Example with a query string parameter:

$ curl https://api.bitbucket.org/1.0/repositories/jespern/django-piston/changesets?limit=2
RELATED TOPICS

Using the bitbucket REST APIs

Labels
  • None
  1. Dec 02, 2010

    Anonymous

    When retrieving large changesets, is there a way to retrieve the complete list of files? It appears to return only a subset of about 60 files.

  2. Apr 18, 2011

    Anonymous

    The "start" parameter works in a bit intereting way. If total changeset is 279 and I request ?start=278 (since first rev is 0, last rev is 278), it returns 278..278-limit. So, if I say ?start=14, I get r14..r0. WOnder why this thing is reversed?

    I'd like to do something like:

    start with $start = 0;

    while ( response = foo->next )

    Unknown macro: {  next request = $start + $limit; # then $start += $limit;  }


    but this does not work with the current scheme.

    1. Jul 05, 2011

      Can you imagine if it was around the other way? changesets?start=100 would mean something different each time because it would offset from the tip instead of the start of the revision chain. The result would change depending on the activity in the repository.

      By doing it this way you can be sure that the results of calling changesets?start=100 will always be the same.

  3. Aug 07, 2011

    Anonymous

    Timestamps have changed and now have a timestamp similar to: 2010-10-11 11:46:28+00:00

  4. Jan 18, 2012

    Anonymous

    how can i get the same info from a branch?

  5. Jan 20, 2012

    Anonymous

    Is there any chance there will be support for adding credentials to such a request? I assume this will only work for public repositories. I have SSH keys, but they're off course ignored making a GET request.

    1. Jan 20, 2012

      Anonymous

      Never mind, found it already by copying it from another request. Like this

      curl --user john:s3cr3t https://api.bitbucket.org/1.0/repositories/john/myrepo/changesets/

  6. Feb 06, 2012

    Can commit comments be retrieved using this API?

    1. Feb 06, 2012

      Commit comments will come back as the "message" property of the changeset resource.

      1. Feb 06, 2012

        Sorry, I should have been clearer. Message seems to be the commit message, I was talking about a list of BitBucket comments that users might have added via web.

        1. Feb 07, 2012

          Looks like you can with https://api.bitbucket.org/1.0/repositories/user/repo/changesets/node/comments.  It looks like you need to be logged in to do that.

           

          1. Feb 07, 2012

            Excellent, thanks!

  7. Feb 12, 2012

    Anonymous

    Is it possible to retrieve the history of a file?

    1. Feb 12, 2012

      It looks like the only thing you can get is the changeset id of the last commit against a file using the Source resource.

  8. Apr 26, 2012

    Anonymous

    Can I use this with private repositories?

    What would I need to pass with the get request?

    https://api.bitbucket.org/1.0/repositories/jespern/django-piston/changesets/?user=jaspern&pass=somepass ?

    Anything like that?

    1. May 05, 2012

      Most RESTFul services are configured to use that. However realize that putting query string credentials in a HTTPS/SSL get/post request will still have the user credentials be in clear-text for anyone "viewing" your network transactions (which is not as difficult as you would think). 

      They currently have BASIC authentication enabled. 

      https://username:password@api.bitbucket.org/1.0/repositories/jespern/django-piston/changesets/

      Believe it or not, the information before the '@' will actually encode to base64 and if sent on a SSL/TSL protocol (which HTTPS is SSL), will encrypt it.... I mean it's not HORRIBLY secure, but it will deter the onlookers much better than writing your credentials out in the URL. 

      Personally I think it would be nice if they set up a new Authentication that digested an API key that didn't contains any security information. At least with an API key credentials cannot be gotten from it.