Kippt is a gem that provides a client library for using Kippt.com API.
Add this line to your application's Gemfile:
gem "kippt"And then execute:
$ bundleOr install it yourself as:
$ gem install kipptTo be able to use the API you need to authenticated. There's two ways to authenticate:
client = Kippt::Client.new(username: "vesan", password: "s3cr3t")
# Methods called on `client` will use the passed credentialsclient = Kippt::Client.new(username: "vesan", token: "2544d6bfddf5893ec8617")
# Methods called on `client` will use the passed credentialsYou can get the account details (username and token):
client = Kippt::Client.new(username: "vesan", token: "2544d6bfddf5893ec8617")
account = client.account
account.username #=> "vesan"
account.token #=> "2544d6bfddf5893ec8617"Always use token instead of the password if possible because it's more secure.
Get all the lists:
client = Kippt::Client.new(username: "vesan", token: "2544d6bfddf5893ec8617")
lists = client.lists.all # Returns Kippt::ListCollectionGet single list:
client = Kippt::Client.new(username: "vesan", token: "2544d6bfddf5893ec8617")
list_id = 10
list = client.lists[list_id] # Returns Kippt::ListItemclient = Kippt::Client.new(username: "vesan", token: "2544d6bfddf5893ec8617")
clips = client.clips.all # Returns Kippt::ClipCollectionBoth ListCollection and ClipCollection are Enumerable.
Lists and clips are paginated:
client = Kippt::Client.new(username: "vesan", token: "2544d6bfddf5893ec8617")
clips = client.clips.all
clips.total_count
clips.offset
clips.limitYou can get next and previous set of results:
clips.next_page? #=> true
clips.next_page # Returns new Kippt::ClipCollection
clips.previous_page? #=> true
clips.previous_page # Returns new Kippt::ClipCollectionLimit and offset can be controlled manually:
client.clips.all(limit: 25, offset: 50)Clips can be searched:
client.clips.search("kippt") #=> Returns Kippt::ClipCollectionOther available options are is\_starred: true and list: [list-id] like:
client.clips.search(q: "kippt", list: 5, is_starred: true)You can create new resources, here for example clips:
clip = client.clips.build
clip.url = "http://github.com"
clip.save #=> Returns booleanIf you are missing required fields #save will return false and you can use
#errors to get the error messages returned by the API.
clip = client.clips.build
clip.save #=> false
clip.errors #=> ["No url."]Deleting resources is done with #destroy:
clip_id = 1001
clip = client.clips[clip_id]
clip.destroy #=> true- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Do your changes
- Run the tests (
rspec spec) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request (
https://github.com/vesan/kippt/pulls)