Ruby Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Gem Version Build Status Dependency Status Code Climate Coverage Status

Simple Ruby wrapper for the GitHub v3 API.


gem install octokit



Show a user

=> <#Hashie::Rash blog="" company="Code for America" created_at="2008/05/14 13:36:12 -0700" email="" followers_count=177 following_count=83 gravatar_id="1f74b13f1e5c6c69cb5d7fbaabb1e2cb" id=10308 location="San Francisco" login="sferik" name="Erik Michaels-Ober" permission=nil public_gist_count=16 public_repo_count=30 type="User">

Show who a user follows

=> ["rails", "puls", "wycats", "dhh", "jm3", "joshsusser", "nkallen", "technoweenie", "blaine", "al3x", "defunkt", "schacon", "bmizerany", "rtomayko", "jpr5", "lholden", "140proof", "ephramzerb", "carlhuda", "carllerche", "jnunemaker", "josh", "hoverbird", "jamiew", "jeremyevans", "brynary", "mojodna", "mojombo", "joshbuddy", "igrigorik", "perplexes", "joearasin", "hassox", "nickmarden", "pengwynn", "mmcgrana", "reddavis", "reinh", "mzsanford", "aanand", "pjhyett", "kneath", "tekkub", "adamstac", "timtrueman", "aaronblohowiak", "josevalim", "kaapa", "hurrycane", "jackdempsey", "drogus", "cameronpriest", "danmelton", "marcel", "r", "atmos", "mbleigh", "isaacs", "maxogden", "codeforamerica", "chadk", "laserlemon", "gruber", "lsegal", "bblimke", "wayneeseguin", "brixen", "dkubb", "bhb", "bcardarella", "elliottcable", "fbjork", "mlightner", "dianakimball", "amerine", "danchoi", "develop", "dmfrancisco", "unruthless", "trotter", "hannestyden", "codahale", "ry"]


For convenience, methods that require a repository argument may be passed in any of the following forms:


Octokit.repo({:username => "pengwynn", :name => "octokit"})

Octokit.repo({:username => "pengwynn", :repo => "octokit"})


=> <#Hashie::Rash created_at="2009/12/10 13:41:49 -0800" description="Simple Ruby wrapper for the GitHub API and feeds" fork=false forks=25 has_downloads=true has_issues=true has_wiki=true homepage="" integrate_branch="master" language="Ruby" name="octokit" open_issues=8 owner="pengwynn" private=false pushed_at="2011/05/05 10:48:57 -0700" size=1804 url="" watchers=92>

List the commits for a repository



=> [#<Hashie::Mash author=#<Hashie::Mash avatar_url="" gravatar_id="7e19cd5486b5d6dc1ef90e671ba52ae0" id=865 login="pengwynn" url=""> commit=#<Hashie::Mash author=#<Hashie::Mash date="2012-10-31T15:17:51Z" email="" name="Wynn Netherland"> comment_count=0 committer=#<Hashie::Mash date="2012-10-31T15:17:51Z" email="" name="Wynn Netherland"> message="Fix bug with archive_link for private repo" tree=#<Hashie::Mash sha="49bf2a476aa819f29b0fc1a8805f7567f010006d" url=""> url=""> committer=#<Hashie::Mash avatar_url="" gravatar_id="7e19cd5486b5d6dc1ef90e671ba52ae0" id=865 login="pengwynn" url=""> parents=[#<Hashie::Mash sha="7a67f4b47791cb77de33e491df87cef06012c79f" url="">] sha="8db3df37fad3a021eb8036b007c718149836cb32" url="">, ... , ...]

Authenticated Requests

For methods that require authentication, you'll need to setup a client with your login and password.

client = => "me", :password => "sekret")

Alternately, you can authenticate with a GitHub OAuth2 token.

client = => "me", :oauth_token => "oauth2token")

Using .netrc for stored credentials

Octokit now supports .netrc files for storing your GitHub Basic Auth credentials. Given a ~/.netrc like the following

machine login pengwynn password 0ct0c4tz4ev3r!

You can make authenticated calls by telling Octokit to use credentials from this file:

Octokit.netrc = true # or /path/to/file
Octokit.user # authenticates as 'pengwynn' user

Requesting a specific media type

You can pass an :accept option value to request a particular media type.

Octokit.contents 'pengwynn/octokit', :path => '', :accept => 'application/vnd.github.html'

Using with GitHub Enterprise

To use with GitHub Enterprise, you'll need to set the API and web endpoints before instantiating a client.

Octokit.configure do |c|
  c.api_endpoint = ''
  c.web_endpoint = ''

@client = => 'USERNAME', :password => 'PASSWORD')

Supported Ruby Versions

This library aims to support and is tested against the following Ruby implementations:

  • Ruby 1.8.7
  • Ruby 1.9.2
  • Ruby 1.9.3
  • Ruby 2.0.0

If something doesn't work on one of these Ruby versions, it's a bug.

This library may inadvertently work (or seem to work) on other Ruby implementations, however support will only be provided for the versions listed above.

If you would like this library to support another Ruby version, you may volunteer to be a maintainer. Being a maintainer entails making sure all tests run and pass on that implementation. When something breaks on your implementation, you will be responsible for providing patches in a timely fashion. If critical issues for a particular implementation exist at the time of a major release, support for that Ruby version may be dropped.


This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision. For example:

spec.add_dependency 'octokit', '~> 1.0'

JSON dependency

Since JSON is included in 1.9 now, we no longer include it as a hard dependency. Please require it explicitly if you're running Ruby 1.8

gem 'json', '~> 1.7'


Octokit was initially created by Wynn Netherland and Adam Stacoviak but has turned into a true community effort. Special thanks to the following core contributors:


Octokit was inspired by Octopi and aims to be a lightweight, less-ActiveResourcey alternative.


Copyright (c) 2011-2013 Wynn Netherland, Adam Stacoviak, Erik Michaels-Ober. See LICENSE for details.