Coder Social home page Coder Social logo

octohub's Introduction

OctoHub: Low level Python and CLI interface to GitHub

OctoHub is a Python package that provides a low level interface to the full GitHub v3 API:

OctoHub was developed out of a need to have a one-to-one interface to the GitHub API based on the excellent online documentation, with the least amount of abstraction.

OctoHub does do its part by parsing raw json responses into Pythonic attribute dictionaries, as well providing an optional iterative Pager for handling pagination.

Also included is a command line interface for quick interaction with GitHub's API.

Speaking of development, it's really easy to leverage the base code to develop higher level tools, see contrib for some examples. We also love pull requests, see our gitflow for guidelines and walk through.

Installation

$ git clone https://github.com/turnkeylinux/octohub.git
$ cd octohub
$ sudo make install

Dependencies

GitHub Token

OctoHub can be used anonymously, but is much more useful when authenticated. You can create a revokable access token under Personal API Tokens in your account settings.

Usage examples (API)

>>> from octohub.connection import Connection

>>> conn = Connection(token)
>>> uri = '/repos/turnkeylinux/tracker/issues'
>>> response = conn.send('GET', uri, params={'labels': 'bug'})
>>> for issue in response.parsed:
...:    print issue.title

>>> from octohub.connection import Pager
>>> pager = Pager(conn, uri)
>>> for issue in pager:
...:    print issue.title

Usage examples (CLI)

# A Personal Access Token from your GitHub account:
#   Account Settings > Applications > Personal Access Tokens > Create new token
$ export OCTOHUB_TOKEN=d34db33fd34db33fd34db33fd34db33fd34db33f
$ export OCTOHUB_LOGLEVEL=INFO
$ octohub GET /repos/turnkeylinux/tracker/issues labels=feature

INFO [response]: status: 200 OK
INFO [response]: x-ratelimit-limit: 5000
INFO [response]: x-ratelimit-remaining: 4997
[
 {
  "body": "...
  "title": "...
  ...


$ cat repo.json
{
  "name": "test",
  "description": "My test project",
  "homepage": "http://www.turnkeylinux.org",
}
$ octohub POST /user/repos --input=repo.json

INFO [response]: status: 201 Created
INFO [response]: x-ratelimit-limit: 5000
INFO [response]: x-ratelimit-remaining: 4996
...

For more example usage:

$ octohub --help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.