Leanpub API wrapper for Ruby
A simple Ruby wrapper for the Leanpub API. Currently supports the API's book summary functions, with aspirations to do more.
Disclaimer: Leanpub is a service of Ruboss Technology Corporation, a corporation incorporated in British Columbia, Canada. I self-publish a book using their service, but am otherwise not affiliated with them in any way.
Requirements
This library has been tested against the following Ruby versions:
- 2.0.0
Installation
Add this line to your application's Gemfile:
gem 'leanpub_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install leanpub_api
Usage
You'll need your book slug and API key values, both of which can be retrieved by accessing your Leanpub account.
The gem currently supports the Leanpub API's book summary functions.
require 'leanpub_api_'
book = LeanpubAPI::BookSummary.new('<book-slug>', '<api-key>')
puts book.title
puts book.subtitle
puts book.slug
puts book.
puts book.url
puts book.title_page_url
puts book.minimum_price
puts book.suggested_price
puts book.total_copies_sold
puts book.total_revenue
puts book.possible_reader_count
Development
Tests expect a .env file at the project's root, with the following
environment variables:
LEANPUB_BOOK_SLUGYour book's Leanpub slugLEANPUB_API_KEYYour Leanpub API key
TODO
Add wrappers for other API functionality:
- Sales summary
- All sales data
- Preview functions
- Publish functions
- Preview/publish job status
- Coupon management
Improve configuration
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes, with tests (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request