module PocketApi

Constants

VERSION

Attributes

access_token[RW]
client_key[RW]

Public Class Methods

add(url, options={}) click to toggle source

Add API Options:

  • title

  • tags - comma-seperated list of tags

  • tweet_id - Twitter tweet_id

# File lib/pocket_api.rb, line 56
def add(url, options={})
  request(:post, '/v3/add', :body => {:url => url}.merge(options))
end
configure(credentials={}) click to toggle source
# File lib/pocket_api.rb, line 12
def configure(credentials={})
  @client_key   = credentials[:client_key]
  @access_token = credentials[:access_token]
end
modify(action, options={}) click to toggle source

Modify API Actions:

  • add

  • archive

  • readd - re-add

  • favorite

  • unfavorite

  • delete

  • tags_add

  • tags_remove

  • tags_replace

  • tags_clear

  • tags_rename

# File lib/pocket_api.rb, line 73
def modify(action, options={})
  request(:post, '/v3/send', :body => {:action => action}.merge(options))
end
request(method, *arguments) click to toggle source
# File lib/pocket_api.rb, line 78
def request(method, *arguments)
  arguments[1] ||= {}
  arguments[1][:body] ||= {}
  arguments[1][:body] = MultiJson.dump(arguments[1][:body].merge({:consumer_key => @client_key, :access_token => @access_token}))
  response = Connection.__send__(method.downcase.to_sym, *arguments)
  raise response.headers["X-Error"] if response.headers["X-Error"]

  response.parsed_response
end
retrieve(options={}) click to toggle source

Retrieve API Options:

  • state unread = only return unread items (default) archive = only return archived items all = return both unread and archived items

  • favorite 0 = only return un-favorited items 1 = only return favorited items

  • tag tag_name = only return items tagged with tag_name untagged = only return untagged items

  • contentType article = only return articles video = only return videos or articles with embedded videos image = only return images

  • sort newest = return items in order of newest to oldest oldest = return items in order of oldest to newest title = return items in order of title alphabetically site = return items in order of url alphabetically

  • detailType simple = only return the titles and urls of each item complete = return all data about each item, including tags, images, authors, videos and more

  • search - search query

  • domain - search within a domain

  • since - timestamp of modifed items after a date

  • count - limit of items to return

  • offset - Used only with count; start returning from offset position of results

# File lib/pocket_api.rb, line 46
def retrieve(options={})
  response = request(:get, "/v3/get", {:body => options})
  response["list"]
end