--- title: "Getting Information From Leanpub" author: "John Muschelli" date: "`r Sys.Date()`" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting Information From Leanpub} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` # leanpubr Package: The goal of `leanpubr` is to provide provides access to the 'Leanpub' 'API' for gathering information about publications and submissions to the 'Leanpub' platform. ## Setting the API key The main thing you need to do is get an API key from Leanpub. You can do this by visiting https://leanpub.com/author_dashboard/settings if you are an author. If you are not an author, I don't believe access to the API is possible. You can pass this `api_key` to functions in Leanpub (almost all prefixed by `lp_`), or you can set the environmental variable `LEANPUB_API_KEY`. You can set this in an interactive `R` session such as: ```r Sys.setenv("LEANPUB_API_KEY" = "YOUR_KEY") ``` or put this in your `~/.Renviron`: ```r LEANPUB_API_KEY = "YOUR_KEY" ``` ## Getting Data about a book You can use `lp_summary` or `lp_book_info`, these are identical, to get information about any book in Leanpub: ```{r, echo = FALSE} Sys.setenv("LEANPUB_API_KEY" = "asdf") ``` ```{r} library(leanpubr) slug = "biostatmethods" res = lp_summary(slug, error = FALSE, verbose = TRUE) res$content ```