• Stars
    star
    351
  • Rank 120,906 (Top 3 %)
  • Language
    Clojure
  • Created almost 13 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Octocat is nothing without his tentacles

Dependencies Status

An octocat is nothing without her tentacles

Tentacles is a Clojure library for working with the Github v3 API. It supports the entire Github API.

This library is the successor to my old clj-github library. clj-github will no longer be maintained.

Usage

This is on clojars, of course. Just add [tentacles "0.5.1"] to your :dependencies in your project.clj file.

CODE!

The library is very simple. It is a very light wrapper around the Github API. For the most part, it replaces keywords with properly formatted keywords, generates JSON for you, etc. Let's try out a few things.

user> (user-repos "amalloy")
; Evaluation aborted.
user> (repos/user-repos "amalloy")
[{:fork false, :pushed_at "2010-12-10T07:37:44Z", :name "ddsolve", :clone_url "https://github.com/amalloy/ddsolve.git", :watchers 1, :updated_at "2011-10-04T02:51:53Z", :html_url "https://github.com/amalloy/ddsolve", :owner {:avatar_url "https://secure.gravatar.com/avatar/1c6d7ce3810fd23f0823bf1df5103cd3?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png", :url "https://api.github.com/users/amalloy", :gravatar_id "1c6d7ce3810fd23f0823bf1df5103cd3", :login "amalloy", :id 368685}, :language "Clojure", :size 1704, :created_at "2010-08-18T16:37:47Z", :private false, :homepage "", :git_url "git://github.com/amalloy/ddsolve.git", :url "https://api.github.com/repos/amalloy/ddsolve", :master_branch nil, :ssh_url "[email protected]:amalloy/ddsolve.git", :open_issues 0, :id 846605, :forks 1, :svn_url "https://svn.github.com/amalloy/ddsolve", :description "Double-dummy solver for contract bridge"} ...]

I cut out most of the output there. If you try it yourself, you'll notice that it produces a ton of output. How can we limit the output? Easily!

user> (repos/user-repos "amalloy" {:per-page 1})
[{:fork false, :pushed_at "2010-12-10T07:37:44Z", :name "ddsolve", :clone_url "https://github.com/amalloy/ddsolve.git", :watchers 1, :updated_at "2011-10-04T02:51:53Z", :html_url "https://github.com/amalloy/ddsolve", :owner {:avatar_url "https://secure.gravatar.com/avatar/1c6d7ce3810fd23f0823bf1df5103cd3?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png", :url "https://api.github.com/users/amalloy", :login "amalloy", :gravatar_id "1c6d7ce3810fd23f0823bf1df5103cd3", :id 368685}, :language "Clojure", :size 1704, :created_at "2010-08-18T16:37:47Z", :private false, :homepage "", :git_url "git://github.com/amalloy/ddsolve.git", :url "https://api.github.com/repos/amalloy/ddsolve", :master_branch nil, :ssh_url "[email protected]:amalloy/ddsolve.git", :open_issues 0, :id 846605, :forks 1, :svn_url "https://svn.github.com/amalloy/ddsolve", :description "Double-dummy solver for contract bridge"}]

This time we actually did get just one item. We explicitly set the number of items allowed per page to 1. The maximum we can set that to is 100 and the default is 30. We can get specific pages of output the same way by using the :page option. Additionally, :all-pages true can be passed, which will return a lazy seq of all items on all pages.

This also introduces an idiom in tentacles: options are a map passed to the last parameter of an API function. The options map also contains authentication data when we need it to:

user> (repos/repos {:auth "Raynes:REDACTED" :per-page 1})
[{:fork true, :pushed_at "2011-09-21T05:37:17Z", :name "lein-marginalia", :clone_url "https://github.com/Raynes/lein-marginalia.git", :watchers 1, :updated_at "2011-11-23T03:27:47Z", :html_url "https://github.com/Raynes/lein-marginalia", :owner {:login "Raynes", :avatar_url "https://secure.gravatar.com/avatar/54222b6321f0504e0a312c24e97adfc1?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png", :url "https://api.github.com/users/Raynes", :gravatar_id "54222b6321f0504e0a312c24e97adfc1", :id 54435}, :language "Clojure", :size 180, :created_at "2011-11-23T03:27:47Z", :private false, :homepage "", :git_url "git://github.com/Raynes/lein-marginalia.git", :url "https://api.github.com/repos/Raynes/lein-marginalia", :master_branch nil, :ssh_url "[email protected]:Raynes/lein-marginalia.git", :open_issues 0, :id 2832999, :forks 0, :svn_url "https://svn.github.com/Raynes/lein-marginalia", :description "A Marginalia plugin to Leiningen "}]

Default options can be specified via with-defaults.

If an API function has no options and authentication would have no uses for that particular call, the options map is not a parameter at all. For API calls that can do different things based on whether or not you are authenticated but authentication is not required, then the options map will be an optional argument. For API calls that require authentication to function at all, the options map is a required argument. Any data that is required by an API call is a positional argument to the API functions. The options map only ever contains authentication info and/or optional input.

Authentication is supported by Github user authentication :auth <username:password> as demonstrated above, or by oauth or oauth2. For oauth use :oauth-token <token> instead of :auth in the options map. Likewise, for oauth2, include :client-id <client_id> :client-token <client_token> in the options map.

You can access useful information returned by the API such as current rate limits, etags, etc. by checking the response with core/api-meta. You can then use this to perform conditional requests against the API. If the data has not changed, the keyword :tentacles.core/not-modified will be returned. This does not consume any API call quota.

user> (core/api-meta (repos/readme "Raynes" "tentacles" {}))
{:links {nil nil}, :etag "\"f1f3cfabbf0f98e0bbaa7aa424f92e75\"", :last-modified "Mon, 28 Jan 2013 21:13:48 GMT", :call-limit 60, :call-remaining 59}

user> (repos/readme "Raynes" "tentacles" {:etag "\"f1f3cfabbf0f98e0bbaa7aa424f92e75\""})
:tentacles.core/not-modified

user> (repos/readme "Raynes" "tentacles" {:if-modified-since "Mon, 28 Jan 2013 21:13:48 GMT"})
:tentacles.core/not-modified

Similarly, you can set an User-Agent to make your requests more friendly and identifiable.

user> (repos/readme "Raynes" "tentacles" {:user-agent "MyPhoneApp"})

The Github API is massive and great. I can't demonstrate every API call. Everything is generally just as easy as the above examples, and I'm working hard to document things as well as possible, so go explore!

Here are some lovely Marginalia docs. I also wrote a demonstrational blog post about Tentacles that I intend to keep updated with future releases.

If you run into something that isn't documented well or you don't understand, look for the API call on the Github API docs. If you feel like it, please submit a pull request with improved documentation. Let's make this the most impressive Github API library around!

Hacking

Running the tests

In order to run the tests, you need to create a testinfo.clj in the root of the checkout with some info required for the tests to run properly. This file is ignored by git, so don't worry about committing auth info. This file should contain a Clojure map like the following:

{:user "" ;; Github username
 :pass "" ;; Github password
 :follows ""} ;; Username of a person that this user follows.

As more tests are written this information may grow.

License

Copyright (C) 2011 Anthony Grimes

Distributed under the Eclipse Public License, the same as Clojure.

More Repositories

1

conch

A flexible library for shelling out in Clojure
Clojure
542
star
2

fs

File system utilities for Clojure.
Clojure
453
star
3

tryclojure

A little web-based Clojure REPL powered by clojail.
HTML
400
star
4

clojail

A control freak's best friend
Clojure
211
star
5

lein-bin

Standalone console executables for your project.
Clojure
154
star
6

lazybot

An IRC bot written in Clojure.
Clojure
151
star
7

refheap

The Reference Heap. A Clojure pastebin powered by Compojure, MongoDB, and Pygments.
Clojure
129
star
8

laser

HTML transformation/templating for people who do that sort of thing and stuff
Clojure
120
star
9

irclj

A simple and small IRC library/bot framework written in Clojure.
Clojure
84
star
10

bultitude

A namespace finder library.
Clojure
62
star
11

lein-pdo

Run multiple leiningen tasks in parallel.
Clojure
51
star
12

lein-newnew

A replacement for 'lein new' with templates.
Clojure
39
star
13

clj-github

Here lies clj-github. He is survived by his son, tentacles: https://github.com/Raynes/tentacles
Clojure
30
star
14

cegdown

A thin Clojure wrapper for the pegdown markdown parsing library
Clojure
25
star
15

findfn

Finding functions, because they're sexy.
Clojure
25
star
16

ororo

A simple and concise Clojure library for working with the Wunderground weather forecasting API.
Clojure
20
star
17

clavatar

A library for getting gravatar images in Clojure.
Clojure
19
star
18

least

A last.fm API client for Clojure
Clojure
12
star
19

gotmilk

A command-line application for working with Github without a browser.
Clojure
11
star
20

lein-gitify

A leiningen plugin for gitifying a project.
Clojure
10
star
21

clhue

An API client for controlling Hue light bulbs.
Clojure
10
star
22

refheap.vim

A Vim plugin for pasting to RefHeap.
Vim Script
10
star
23

moments

A cron-like task scheduling library using ScheduledExecutorServices and Chronicle.
Clojure
10
star
24

cereal

Simple serialization library with pluggable backends.
Clojure
10
star
25

slackhog

A backup tool for slack.
Clojure
9
star
26

yams

Rewrite of Erik's Amazon Echo RX-V receiver controller as an Alexandra app
Python
8
star
27

filevents

A file system watching library.
Clojure
8
star
28

rxvc

A lightspeed Yamaha RX-V series receiver controller for your command line
Python
8
star
29

refheap.el

An Emacs mode for pasting to https://refheap.com
Emacs Lisp
8
star
30

clj-config

A simple and small configuration library based around Clojure datastructures.
Clojure
7
star
31

morphin

Polymorphic ranges in Clojure
Clojure
7
star
32

basement

Extensible Python project scaffolding brought to you by mustache
Python
6
star
33

dox

A leiningen plugin for creating/updating gh-pages.
Clojure
6
star
34

innuendo

An API library for http://refheap.com
Clojure
6
star
35

hobbit

A Clojure library for interacting with all sorts of URL shortening services.
Clojure
6
star
36

turntable

A service for running SQL queries every n minutes.
Clojure
6
star
37

lein-findfn

Find things.
Clojure
5
star
38

webrepl

A Clojure REPL applet based on Beanshell's JConsole Swing component.
Java
5
star
39

fsutils

Haskell file manipulation utilities.
Haskell
5
star
40

rapture

A refheap command line tool written in Elixir
Elixir
5
star
41

awsenv-profiles

Simple AWS credential profile switcher.
Python
5
star
42

barrelroll

An ES6, atom-shell, hipster as a motherfucker consolidated desktop dashboard for your finances.
JavaScript
4
star
43

fucktheac

Air conditioner -> Chromecast volume control because why not
Python
4
star
44

reap

A refheap API client library in Elixir.
Elixir
4
star
45

areyoustillthere

Email validation for Python
Python
4
star
46

clonesearch

A tool for cloning github repos based on a search query.
Python
4
star
47

cassette

A great place to store sequential data, based on Kafka's storage format.
Clojure
4
star
48

pygments-tomorrow-night-bright

A tomorrow-night-bright color theme implementation for Pygments.
Python
4
star
49

updoc

A tool written in Clojure for generating an email from closed issues in a Github milestone and then emailing it to someone
Clojure
3
star
50

refh

A command-line tool for pasting to refheap.
Haskell
3
star
51

coffeefilter

Quick coffeescript to javascript compilation in Atom
CoffeeScript
3
star
52

closed

Open files in Atom with paths.
CoffeeScript
3
star
53

pyheap

Python implementaion of the Refheap API
Python
3
star
54

repl-in-chrome

Try repl in the chrome
JavaScript
2
star
55

haskheap

Haskell bindings to the refheap API
Haskell
2
star
56

intime

WIP time tracking restful web service.
JavaScript
2
star
57

octopress-blog

Experimental bloggy stuff
JavaScript
2
star
58

cake-autodoc

A plugin for generating autodoc documentation with cake.
Clojure
2
star
59

TConfig

A simple text-based key-value configuration library and parser.
Haskell
2
star
60

tallyho

A general score keeping application written in Clojure.
Clojure
2
star
61

lein-tag

Let lein tag your releases for you.
Clojure
2
star
62

dotemacsdotd

My .emacs.d folder
Emacs Lisp
2
star
63

vimfiles

My vimfiles.
Vim Script
1
star
64

cake-slamhound

A cake plugin for using slamhound.
Clojure
1
star
65

rubeque

Competitive learning site for ruby.
JavaScript
1
star
66

micdrop

A sound server for recording with a USB mic and streaming it.
JavaScript
1
star
67

clippard

Cross-platform copying to system clipboard.
Haskell
1
star
68

famine

sekrit
Elixir
1
star
69

beepy

Experimental beeline wrapper for Python (for Hive)
Python
1
star
70

amsin

A Python program for turning long amazon links into short amzn links.
Python
1
star
71

sherlock

A library for downloading and searching maven lucene indexes.
Clojure
1
star
72

explain

Dump the create table statement from a postgres (or redshift) instance.
Python
1
star
73

echolight

Presets for hue lights with Amazon Echo
Python
1
star
74

refheap-blog

The refheap octopress blog.
JavaScript
1
star
75

grunt-doxy

Markdown documentation generator plugin for grunt via dox and doxme
JavaScript
1
star
76

meteor-accounts-pg

Postgres/Redshift account adapter for Meteor accounts
CoffeeScript
1
star
77

quarantine

Isolated virtualenvs for Python programs.
Python
1
star
78

rubyheap

A Ruby API library for RefHeap.
Ruby
1
star
79

edited-tentacles-test2

I'm an edited test repository, just to make sure tentacles is working properly. Ignore me.
1
star
80

cake-github

A command-line interface to the Github API as a cake plugin. Tasty.
Clojure
1
star
81

udder

An utterance generator tool for Amazon Echo apps
JavaScript
1
star
82

Hricket

An implementation of Cricket in Haskell.
Haskell
1
star
83

lein-hammock

Hammock time!
Clojure
1
star
84

submodulize

An Elixir script for making a directory full of git repos into submodules
Elixir
1
star
85

mkvrename

A little tool for renaming mkv files in my television show ripping structure.
Clojure
1
star