Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GitHub API

Robert Reiz
December 14, 2013

GitHub API

A short intro to the GitHub API.
I created this slides for the GIT MeetUp in Berlin in Dezember 2013.

Robert Reiz

December 14, 2013
Tweet

More Decks by Robert Reiz

Other Decks in Programming

Transcript

  1. GitHub API
    VersionEye

    View Slide

  2. http://developer.github.com/

    View Slide

  3. Use Cases
    • Login
    • Fetching Repositories / Files
    • Crawling Licenses / Change logs and more
    • Fetching commit dates from tags (release dates)

    View Slide

  4. Authentication
    • Application Authentication
    • User Authentication (OAuth - user token)

    View Slide

  5. Rate Limit
    • 50 per Hour for unauthenticated requests
    • 5000 per Hour for authenticated requests

    View Slide

  6. Example: Fetching a user

    View Slide

  7. url = "https://api.github.com/user"

    View Slide

  8. Don’t do that!
    !
    Use Octokit!

    View Slide

  9. https://www.versioneye.com/ruby/octokit/2.6.3
    Octokit - Ruby client for the GitHub API

    View Slide

  10. client = Octokit::Client.new( :access_token => token )
    client.user.to_json

    View Slide

  11. View Slide

  12. TESTING

    View Slide

  13. https://www.versioneye.com/ruby/vcr/2.8.0
    VCR

    View Slide

  14. View Slide

  15. Prepare for failure!

    View Slide

  16. Exceptions
    • GitHub API can be down
    • Tokens can be revoked
    • Rate limit can exceed faster then you think
    • The API can change

    View Slide

  17. Q / A
    @RobertReiz

    View Slide