Unofficial hypothesis ruby gem.

Installation

gem install hypothesis

Usage

You'll need to generate an API token on your Hypothesis developer page.

require 'rubygems'
require 'hypothesis'

hypothesis = Hypothesis::API.new('YOUR_HYPOTHESIS_API_KEY')
puts hypothesis.search({ user: 'javier', limit: 10 })

That will output a Hash with the found items:

 => {"rows"=>[{"updated"=>"2016-08-21T13:08:33.877253+00:00", "group"=>"__world__", "target"=>[{"source"=>"http://thelongandshort.org/society/war-on-cash", "selector"=>[{"endContainer"=>"/main[1]/article[1]/div[1]/div[6]/div[1]/p[3]", "startContainer"=>"/main[1]/article[1]/div[1]/div[6]/div[1]/p[3]", "type"=>"RangeSelector", "startOffset"=>0, "endOffset"=>368}, {"type"=>"TextPositionSelector", "end"=>9811, "start"=>9443}, {"exact"=>"Anyone defending cash in this context will be labelled as an anti-progress, reactionary, and nostalgic Luddite. That's why we must not defend cash. Rather, we should focus on pointing out that the Death of Cash means the Rise of Something Else. We are fighting a broader battle to maintain alternatives to the growing digital panopticon that is emerging all around us.", "prefix"=>"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "type"=>"TextQuoteSelector", "suffix"=>"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}]}], "links"=>{"json"=>"https://hypothes.is/api/annotations/XUdzmGegAeaMle8incguxg", "html"=>"https://hypothes.is/a/XUdzmGegEeaNle8inzguxg", "incontext"=>"https://hyp.is/XUdzmGegAeaMle8incguxg/thelongandshort.org/society/war-on-cash"}, "tags"=>[], "text"=>"", "created"=>"2016-08-21T13:08:33.877245+00:00", "uri"=>"http://thelongandshort.org/society/war-on-cash", "user"=>"acct:[email protected]", "document"=>{"title"=>["The War on Cash"]}, "id"=>"XUdzmGegAeaMle8incguxg", "permissions"=>{"read"=>["acct:[email protected]"], "admin"=>["acct:[email protected]"], "update"=>["acct:[email protected]"], "delete"=>["acct:[email protected]"]}}], "total"=>1}

Currently this gem only supports the root, search, and read endpoints.

API reference

The Hypothesis API

License

This work is licensed under the MIT License (MIT) and it is not associated with TinyLetter in any way.