The new Leanpub API helps writers publish their own work in ebook format and provides instant access to sales data. Leanpub is an online marketplace that enables writer’s to sell their ebooks in a variety of formats. Writers receive a 90% royalty (minus 50 cents) off each sale and are not prohibited from simulataneously selling their book on other marketplaces like Amazon.
Unique to LeanPub, writers – particularly for computer programming books – are encouraged to publish works-in-progress and pivot their text based on reader feedback until they create a viable book product.
To do this, Leanpub provides an editing language and self-publishing workflow that allows writers to submit their work and convert the material into several formats including PDF, EPUB and Kindle. The Leanpub API allows authors to manage their workflow direct from their preferred editor.
Speaking with ProgrammableWeb, co-founder Scott Patten explained:
“When you sign up for Leanpub, we share a Dropbox folder with you. You then write your book by creating and editing Markdown files in that folder. There's a special file called "Book.txt" that just contains a list of the files that you want included in your book. We also put the PDF, epub and mobi files in the Dropbox folder when we're done generating the book.
So, even without the API there wasn't a lot of work to do to start a preview of your book -- you just went to the preview page for your book on Leanpub and clicked a button.
But switching to a web page can take you out of your flow, and it doesn't allow you to do things like set up Continuous Integration for your book, or see what step the book generation is on without switching to your browser. We wanted to enable that and, hopefully, see our authors do some wonderful, crazy things that we never envisioned."
The LeanPub API uses a REST protocol and returns data in XML and JSON formats.
Patten explains how he hopes developers will use the API:
"We're hoping to see people integrate it into their editors so that they can publish or preview their book from their editor. I'm looking forward to the day when I can do `Meta-X leanpub-preview` in Emacs (I may write this myself if someone doesn't beat me to it). We also provide an API for getting updates on the book generation process, so it'd be great to see them displayed in the editor somewhere.
In the broader picture, we're creating a spec for the superset of Markdown used on Leanpub that we call Leanpub Flavoured Markdown. We're hoping to see editors provide support for both Leanpub Flavoured Markdown and the API for a nicely integrated Leanpub writing experience. Authors are just as opinionated about their tools as programmers are, and there is lots of room for different tools here. You can imagine one that provides a very simple, clean experience with a text editor and a preview Function, one that gives you a full-blown WYSIWYG experience, and another that's a gorgeous iPad app.
There are already a couple of Markdown editors that work with Leanpub Flavoured Markdown, but we're going to make it easier on them by actually locking down and documenting the spec, as well as providing the API to allow you to spend all day in your editor without needing to switch over to a web browser."
Self-publishing and in-progress release of draft books is a fast-growing sector of the book publishing market, and is increasingly being chosen as a preferred business model especially for technical and trade works. In their guide APE: Author, Publisher, Entrepreneur, Guy Kawaski and Shawn Welch explain how agile development is the future of trade and technical book writing. In-progress releases encourage reader response to early drafts and provides writers with the opportunity to keep their work up to date in fast-moving sectors that have constantly emerging new techniques and ideas. They themselves are committed to monthly updates of APE noting “…in a trade book like APE, where the subject matter changes often, we think this is a major advantage of ebook technology.” Leanpub makes this technology available to writers via their web interface and API tools.
“We're just starting on this, so we're really looking for feedback and ideas. If you want to use the API in your product, but you really need a change, let us know and we'll see what we can do. If you do develop something, let us know and we'll tell our authors about it.”