| Version: | 0.4.0 | 
| Title: | 'Leanpub' API Interface | 
| Description: | Provides access to the 'Leanpub' API https://leanpub.com/help/api for gathering information about publications and submissions to the 'Leanpub' platform. | 
| License: | GPL-3 | 
| Imports: | httr, xml2, jsonlite, assertthat | 
| Suggests: | knitr, rmarkdown, covr, testthat | 
| Encoding: | UTF-8 | 
| ByteCompile: | true | 
| Type: | Package | 
| Maintainer: | John Muschelli <muschellij2@gmail.com> | 
| VignetteBuilder: | knitr | 
| URL: | https://github.com/muschellij2/leanpubr | 
| BugReports: | https://github.com/muschellij2/leanpubr/issues | 
| RoxygenNote: | 7.3.2 | 
| NeedsCompilation: | no | 
| Packaged: | 2025-04-01 15:57:09 UTC; johnmuschelli | 
| Author: | John Muschelli | 
| Repository: | CRAN | 
| Date/Publication: | 2025-04-01 16:50:02 UTC | 
Find API Key for Leanpub
Description
Determines if Leanpub API Key is set. If not, it stops and returns an error. If so, returns the value.
Usage
lp_api_key(api_key = NULL, error = TRUE)
lp_have_api_key(api_key = NULL)
Arguments
| api_key | Leanpub API key ( | 
| error | Should the function error if  | 
Value
Character API key
Note
You can either set the API key or have it accessible by
api_key = Sys.getenv('LEANPUB_API_KEY').
Examples
res = lp_api_key(error = FALSE)
lp_have_api_key()
Leanpub Base URL
Description
Leanpub Base URL
Usage
lp_base_url(secure = TRUE)
Arguments
| secure | Should https be used (may be necessary) | 
Value
Character vector (length 1) of URL
Examples
lp_base_url()
Leanpub Book Information
Description
Leanpub Book Information
Usage
lp_book_info(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_summary(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
Arguments
| slug | slug of the project | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| ... | additional options to pass to  | 
Value
List of the result of the GET call and
the content
Note
See https://leanpub.com/help/api
Examples
if (lp_have_api_key()) {
stat = lp_book_info(slug = "modernscientist")
}
Leanpub Coupons
Description
Leanpub Coupons
Usage
lp_coupons(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
Arguments
| slug | slug of the project | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| ... | additional options to pass to  | 
Value
List of the result of the GET call and
the content
Note
See https://leanpub.com/help/api
Leanpub Download Latest Version
Description
Leanpub Download Latest Version
Usage
lp_download(
  slug,
  format = c("pdf", "epub"),
  api_key = NULL,
  secure = TRUE,
  verbose = TRUE,
  ...
)
Arguments
| slug | slug of the project | 
| format | format of the book to download | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| ... | additional options to pass to  | 
Value
List of the result of the GET call and
the content
Note
See https://leanpub.com/help/api
Examples
if (lp_have_api_key()) {
slug = "biostatmethods"
res = lp_download(slug, verbose = FALSE, nonstop = TRUE, error = FALSE,
format = "epub")
file.exists(res)
}
Leanpub Wrapper for GET/POST statements
Description
Leanpub Wrapper for GET/POST statements
Usage
lp_get_wrapper(
  slug,
  endpoint,
  api_key = NULL,
  secure = TRUE,
  verbose = TRUE,
  ...
)
lp_post_wrapper(
  slug,
  endpoint,
  api_key = NULL,
  secure = TRUE,
  verbose = TRUE,
  ...
)
Arguments
| slug | slug of the project | 
| endpoint | call to the api endpoint | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| ... | additional options to pass to  | 
Value
List of the result of the GET call and
the content
Note
See https://leanpub.com/help/api
Examples
if (lp_have_api_key()) {
stat = lp_get_wrapper(slug = "neuroimagingforstatisticians",
    endpoint = "/job_status", nonstop = TRUE, error = FALSE)
}
Leanpub Job Status
Description
Leanpub Job Status
Usage
lp_job_status(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
Arguments
| slug | slug of the project | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| ... | additional options to pass to  | 
Value
List of the result of the GET call and
the content
Note
See https://leanpub.com/help/api
Examples
if (lp_have_api_key()) {
stat = lp_job_status(slug = "neuroimagingforstatisticians",
nonstop = TRUE, error = FALSE)
}
Leanpub Links
Description
Leanpub Links
Usage
lp_links(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
Arguments
| slug | slug of the project | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| ... | additional options to pass to  | 
Value
List of URLs
Note
See https://leanpub.com/help/api
Examples
if (lp_have_api_key()) {
slug = "biostatmethods"
res = lp_links(slug, nonstop = TRUE, error = FALSE)
}
Leanpub Preview
Description
Leanpub Preview
Usage
lp_preview(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
Arguments
| slug | slug of the project | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| ... | additional options to pass to  | 
Value
List of the result of the GET call and
the content
Note
See https://leanpub.com/help/api
Examples
## Not run: 
if (lp_have_api_key()) {
slug = "neuroimagingforstatisticians"
res = lp_preview(slug, nonstop = FALSE, error = FALSE)
}
## End(Not run)
Leanpub Publish
Description
Leanpub Publish
Usage
lp_publish(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
Arguments
| slug | slug of the project | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| ... | additional options to pass to  | 
Value
List of the result of the GET call and
the content
Note
See https://leanpub.com/help/api
Examples
if (lp_have_api_key()) {
slug = "neuroimagingforstatisticians"
res = lp_publish(slug, nonstop = TRUE, error = FALSE)
}
Leanpub Quiz Responses for a Course
Description
Leanpub Quiz Responses for a Course
Usage
lp_quiz_responses(
  slug,
  anonymized_id = NULL,
  body = list(),
  api_key = NULL,
  secure = TRUE,
  verbose = TRUE,
  query = list(),
  ...
)
Arguments
| slug | slug of the project | 
| anonymized_id | Anonymized ID for a single user. For a single user's CSV, you will get the JSON response immediately. | 
| body | body sent to  | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| query | query information to send to  | 
| ... | additional options to pass to  | 
Value
List of the result of the POST call and
the content
Note
See Author -> Courses -> Course Name -> Quiz Responses on Leanpub
Examples
## Not run: 
if (lp_have_api_key()) {
slug = "muschellitestcourse"
res = lp_quiz_responses(slug, error = FALSE, verbose = 2)
}
## End(Not run)
Leanpub Sales Information
Description
Leanpub Sales Information
Usage
lp_sales(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_all_sales(
  slug,
  api_key = NULL,
  secure = TRUE,
  verbose = TRUE,
  page = NULL,
  ...
)
lp_next_url(result)
lp_next(result, ...)
Arguments
| slug | slug of the project | 
| api_key | API key for Leanpub, passed to  | 
| secure | passed to  | 
| verbose | print diagnostic messages | 
| ... | additional options to pass to  | 
| page | page to extract for sales | 
| result | an object of class 'lp_results', which must have a 'response' slot in a list | 
Value
List of the result of the GET call and
the content
Note
See https://leanpub.com/help/api
Examples
## Not run: 
if (lp_have_api_key()) {
res1 = lp_all_sales(slug = "biostatmethods")
nurl = lp_next_url(res1)
res_next = lp_next(res1)
}
## End(Not run)