No commit activity in last 3 years
No release in over 3 years
Ruby wrapper for Theoldreader's API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0
>= 0

Runtime

 Project Readme

Theoldreader::Api

Ruby wrapper for Theoldreader's API.

Gem Version

Installation

Add this line to your application's Gemfile:

gem 'theoldreader-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install theoldreader-api

Usage

Authentication

First you need to obtain a token for theoldreader user:

require 'theoldreader-api'

Theoldreader::Api.new.accounts_clientlogin(
  Email: 'test@krasnoukhov.com', Passwd: '...', client: 'YourAppName'
)
=> {"SID"=>"none", "LSID"=>"none", "Auth"=>"LyTEJPvTJiSPrCxLu46d"}

Generic

api = Theoldreader::Api.new("LyTEJPvTJiSPrCxLu46d")

api.call!('get', '/reader/api/0/user-info', {output: 'json'})

call! will pass every option you provide directly to Theoldreader's Api.

Shortcut

api.call('user-info')

api.call('subscription/quickadd', quickadd: 'http://xkcd.com')

api.call('tag/list')

api.call('/reader/subscriptions/export')

call will filter your options to include only those listed in specification for the given endpoint.

call accepts endpoints from Theoldreader::Api::ENDPOINTS.keys as its first argument.

Theoldreader::Api::ENDPOINTS includes all available methods from Theoldreader's API (with 'reader/api/0/' being left out), except those three wich returns specific atom feeds (https://theoldreader.com/reader/atom/...). You can access them if you want with call!

Shortcuts for shortcuts

If you mentally process your endpoint through .downcase.sub(%r{^/+}, '').gsub(%r{[-/]}, '_') you should also get available method for Api.

# to get userinfo
api.user_info

# to add new feed
api.subscription_quickadd(quickadd: 'http://xkcd.com')

# to get the last two unread items
api.stream_contents(
  s: 'user/-/state/com.google/reading-list',
  xt: 'user/-/state/com.google/read',
  n: 2
)

Works only for keys listed in Theoldreader::Api::ENDPOINTS.keys

Advanced Usage

You can change faraday adapter:

require 'net/http/persistent'

Theoldreader::Api.new('LyTEJPvTJiSPrCxLu46d', {adapter: :net_http_persistent})

And you can use API via http instead of https:

Theoldreader::Api.new('LyTEJPvTJiSPrCxLu46d', {use_ssl: false})

TODO

Write specs

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ilzoff/theoldreader-api.

License

The gem is available as open source under the terms of the MIT License.