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. |
Authors: | John Muschelli [aut, cre] |
Maintainer: | John Muschelli <[email protected]> |
License: | GPL-3 |
Version: | 0.3.2 |
Built: | 2024-11-02 06:14:07 UTC |
Source: | https://github.com/muschellij2/leanpubr |
Determines if Leanpub API Key is set. If not, it stops and returns an error. If so, returns the value.
lp_api_key(api_key = NULL, error = TRUE) lp_have_api_key(api_key = NULL)
lp_api_key(api_key = NULL, error = TRUE) lp_have_api_key(api_key = NULL)
api_key |
Leanpub API key ( |
error |
Should the function error if |
Character API key
You can either set the API key or have it accessible by
api_key = Sys.getenv('LEANPUB_API_KEY')
.
res = lp_api_key(error = FALSE) lp_have_api_key()
res = lp_api_key(error = FALSE) lp_have_api_key()
Leanpub Base URL
lp_base_url(secure = TRUE)
lp_base_url(secure = TRUE)
secure |
Should https be used (may be necessary) |
Character vector (length 1) of URL
lp_base_url()
lp_base_url()
Leanpub Book Information
lp_book_info(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...) lp_summary(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_book_info(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...) lp_summary(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
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 |
List of the result of the GET
call and
the content
See https://leanpub.com/help/api
if (lp_have_api_key()) { stat = lp_book_info(slug = "modernscientist") }
if (lp_have_api_key()) { stat = lp_book_info(slug = "modernscientist") }
Leanpub Coupons
lp_coupons(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_coupons(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
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 |
List of the result of the GET
call and
the content
See https://leanpub.com/help/api
Leanpub Download Latest Version
lp_download(slug, format = c("pdf", "mobi", "epub"), api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_download(slug, format = c("pdf", "mobi", "epub"), api_key = NULL, secure = TRUE, verbose = TRUE, ...)
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 |
List of the result of the GET
call and
the content
See https://leanpub.com/help/api
if (lp_have_api_key()) { slug = "biostatmethods" res = lp_download(slug, verbose = FALSE, nonstop = TRUE, error = FALSE, format = "mobi") file.exists(res) }
if (lp_have_api_key()) { slug = "biostatmethods" res = lp_download(slug, verbose = FALSE, nonstop = TRUE, error = FALSE, format = "mobi") file.exists(res) }
Leanpub Wrapper for GET/POST statements
lp_get_wrapper(slug, endpoint, api_key = NULL, secure = TRUE, verbose = TRUE, ...) lp_post_wrapper(slug, endpoint, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_get_wrapper(slug, endpoint, api_key = NULL, secure = TRUE, verbose = TRUE, ...) lp_post_wrapper(slug, endpoint, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
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 |
List of the result of the GET
call and
the content
See https://leanpub.com/help/api
if (lp_have_api_key()) { stat = lp_get_wrapper(slug = "neuroimagingforstatisticians", endpoint = "/job_status", nonstop = TRUE, error = FALSE) }
if (lp_have_api_key()) { stat = lp_get_wrapper(slug = "neuroimagingforstatisticians", endpoint = "/job_status", nonstop = TRUE, error = FALSE) }
Leanpub Job Status
lp_job_status(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_job_status(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
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 |
List of the result of the GET
call and
the content
See https://leanpub.com/help/api
if (lp_have_api_key()) { stat = lp_job_status(slug = "neuroimagingforstatisticians", nonstop = TRUE, error = FALSE) }
if (lp_have_api_key()) { stat = lp_job_status(slug = "neuroimagingforstatisticians", nonstop = TRUE, error = FALSE) }
Leanpub Links
lp_links(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_links(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
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 |
List of URLs
See https://leanpub.com/help/api
if (lp_have_api_key()) { slug = "biostatmethods" res = lp_links(slug, nonstop = TRUE, error = FALSE) }
if (lp_have_api_key()) { slug = "biostatmethods" res = lp_links(slug, nonstop = TRUE, error = FALSE) }
Leanpub Preview
lp_preview(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_preview(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
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 |
List of the result of the GET
call and
the content
See https://leanpub.com/help/api
## Not run: if (lp_have_api_key()) { slug = "neuroimagingforstatisticians" res = lp_preview(slug, nonstop = FALSE, error = FALSE) } ## End(Not run)
## Not run: if (lp_have_api_key()) { slug = "neuroimagingforstatisticians" res = lp_preview(slug, nonstop = FALSE, error = FALSE) } ## End(Not run)
Leanpub Publish
lp_publish(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
lp_publish(slug, api_key = NULL, secure = TRUE, verbose = TRUE, ...)
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 |
List of the result of the GET
call and
the content
See https://leanpub.com/help/api
if (lp_have_api_key()) { slug = "neuroimagingforstatisticians" res = lp_publish(slug, nonstop = TRUE, error = FALSE) }
if (lp_have_api_key()) { slug = "neuroimagingforstatisticians" res = lp_publish(slug, nonstop = TRUE, error = FALSE) }
Leanpub Quiz Responses for a Course
lp_quiz_responses(slug, anonymized_id = NULL, body = list(), api_key = NULL, secure = TRUE, verbose = TRUE, query = list(), ...)
lp_quiz_responses(slug, anonymized_id = NULL, body = list(), api_key = NULL, secure = TRUE, verbose = TRUE, query = list(), ...)
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 |
List of the result of the POST
call and
the content
See Author -> Courses -> Course Name -> Quiz Responses on Leanpub
## Not run: if (lp_have_api_key()) { slug = "muschellitestcourse" res = lp_quiz_responses(slug, error = FALSE, verbose = 2) } ## End(Not run)
## Not run: if (lp_have_api_key()) { slug = "muschellitestcourse" res = lp_quiz_responses(slug, error = FALSE, verbose = 2) } ## End(Not run)
Leanpub Sales Information
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, ...)
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, ...)
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 |
List of the result of the GET
call and
the content
See https://leanpub.com/help/api
## 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)
## 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)