python-bitbucket /

Filename Size Date modified Message
73 B
1.1 KB
35 B
2.4 KB
24 B
27 B
1.2 KB


DISCLAIMER: This is a potentially unstable fork. It's not quite compatible with the original fork, and screen-scrapes some data not readily available from the api.

A simple python library to access the BitBucket API. API Coverage is not that high at the moment as the API has not been officially released and is still in a state of flux. Right now only read (GET) calls are supported.


API Usage all stems from the BitBucket object. You can instantiate one easily:

>>> import bitbucket
>>> bb = bitbucket.BitBucket()
>>> bb
<BitBucket API>

Certain areas of bitbucket's API require authentication or promise to provide more data if you are authenticated. Authentication lives on the BitBucket object, so if you want to authenticate pass the username and password:

>>> bb = bitbucket.BitBucket('jmoiron', 'mypassword')
>>> bb
<BitBucket API (auth: jmoiron)>

If at any time you set both the username and password attributes on the bb object, authentication becomes active. BitBucket's auth is HTTP Basic over https.

getting data

BitBucket provides an object-oriented wrapper around the API's REST structure. Top level API calls are available off the BitBucket object itself. To fetch a user, and poke around at his repositories:

   >>> jmoiron = bb.user('jmoiron')
   >>> jmoiron
   <User: jmoiron>
   >>> jmoiron.repositories()
   [{'description': 'simple python bitbucket API library',
    'followers_count': 1,
    'name': 'python-bitbucket',
    'slug': 'python-bitbucket',
    'website': ''},
   ... ]
   >>> pybb = jmoiron.repository('python-bitbucket')
   >>> pybb
   <Repository: jmoiron's python-bitbucket>
   >>> pybb.tags()
   >>> pybb.branches()

``python-bitbucket`` does not attempt to format or abstract the return values
of API calls in any way.


There are some basic nosetests in the bitbucket/tests directory. Running these requires nose. This repo is used as the targe for testing the bitbucket api.

See the included requirements.txt file in order to run the tests:

pip install -r requirements.txt

Then to run the tests: