Skip to the content.


Tinybucket is a ruby wrapper library to use Bitbucket Cloud REST APIs with OAuth Authentication.

This gem is inspired by vongrippen/bitbucket.

Sample Code.

At first, I’ll show you how you can use tinybucket gem.

require 'rubygems'
require 'bundler/setup'

require 'tinybucket'

Tinybucket.configure do |config|
  # OAuth1 token/secret if you want to use OAuth1, not OAuth2.
  config.oauth_token = '<your oauth token>'
  config.oauth_secret = '<your oauth secret>'

  # OAuth2 access_token if you want to use OAuth2, not OAuth1.
  config.access_token = '<your oauth2 access_token>'

bucket =

### Iterate team repository
# Fetch a team.
team ='our_great_team')

# A team has many repositories.
team.repos.each do |repo|
  puts "#{}"

  # Repository has branches. do |name|
    puts "branch: #{name}"

### Iterate pull requests on the user's repository.
# Fetch a user.
user = bucket.user('your_username')

# Same as a team, a user has many repositories.
# But just now, fetch a repository which owned by the user.
repo = user.repo('my_great_repo')

# A repository has many pull requests.
# This code show pull requests which has 'OPEN' state.
repo.pull_requests(state: 'OPEN')
  .map { |pr| puts "#{pr.state} - #{['username']} - #{pr.title}" }

# And show pull requests which has 'MERGED' state.
repo.pull_requests(state: 'MERGED')
  .map { |pr| puts "#{pr.state} - #{pr.title} - #{}" }


This gem has these features.



After v1.0.0, tinybucket gem support lazy enumerator !

This feature make your code more rubyish, like this.

# get enumerator to enumerate repositories.
repos = bucket.repos('myname')

# Select repositories which has 2 pull requests to be reviewed.
repo_names = repos('my_name').select do |repo|
  repo.pull_requests.size > 2

This enumerable feature depends on Paging through object collections at Bitbucket Cloud REST API.

NOTE: About size attribute

object collections wrapper has size attribute at Bitbucket Cloud REST API.

The size attribute describe as optional attribute.

In tinybucket gem, collection size depend on side attribute of object collections wrapper in Bitbucket Cloud REST API.

So enumerator’s size attribute may return nil.

Supported APIs

tinybucket gem does not support all of Bitbucket Cloud REST APIs, just now.

Pull requests are welcome. :smile:


=> HowToUse


See LICENSE file.