Package 'leanpubr'

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

Help Index


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 (Sys.getenv('LEANPUB_API_KEY'))

error

Should the function error if api_key = NULL?

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 lp_api_key

secure

passed to lp_base_url for https

verbose

print diagnostic messages

...

additional options to pass to GET

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 lp_api_key

secure

passed to lp_base_url for https

verbose

print diagnostic messages

...

additional options to pass to GET

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", "mobi", "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 lp_api_key

secure

passed to lp_base_url for https

verbose

print diagnostic messages

...

additional options to pass to GET

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 = "mobi")
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 lp_api_key

secure

passed to lp_base_url for https

verbose

print diagnostic messages

...

additional options to pass to GET

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 lp_api_key

secure

passed to lp_base_url for https

verbose

print diagnostic messages

...

additional options to pass to GET

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 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 lp_api_key

secure

passed to lp_base_url for https

verbose

print diagnostic messages

...

additional options to pass to GET

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 lp_api_key

secure

passed to lp_base_url for https

verbose

print diagnostic messages

...

additional options to pass to GET

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 POST

api_key

API key for Leanpub, passed to lp_api_key

secure

passed to lp_base_url for https

verbose

print diagnostic messages

query

query information to send to POST

...

additional options to pass to GET

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 lp_api_key

secure

passed to lp_base_url for https

verbose

print diagnostic messages

...

additional options to pass to GET

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)