python-bitbucket /

Filename Size Date modified Message
bitbucket
docs
tests
73 B
1.0 KB
35 B
1.8 KB
27 B
1.2 KB

python-bitbucket

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.

usage

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': 'http://bitbucket.org/jmoiron/python-bitbucket/'},
   ... ]
   >>> 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.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.