A lightweight R client for the Substack API. All functions return data frames, handle errors with informative messages, and work out of the box once you’ve set your API key.
From CRAN:
install.packages("substackR")
Development version from GitHub:
# install.packages("pak") # if needed
::pak("posocap/substackR") pak
Provide your API key once per session with:
library(substackR)
set_substack_key("your-substack-api-key")
If you haven’t set the key, any API call will prompt you to call
set_substack_key()
first.
Fetches the latest posts.
<- get_substack_latest(
latest_posts publication_url = "posocap.substack.com",
limit = 10,
offset = 0
)
Returns a data frame with columns:
Fetches the top (most liked) posts.
<- get_substack_top("posocap.substack.com", limit = 5) top_posts
Searches posts by keyword.
<- get_substack_search(
search_results publication_url = "posocap.substack.com",
query = "data science",
limit = 20
)
Retrieves a single post by slug.
<- get_substack_post(
single_post publication_url = "posocap.substack.com",
slug = "your-post-slug"
)
set_substack_key()
.cli::cli_abort()
with status code and message.Fork the repo
Create a branch (e.g. feature/xyz
)
Install dependencies:
::install_deps(dependencies = TRUE) devtools
Run tests:
::test() devtools
Submit a pull request.
MIT © Posocap.com
See LICENSE
for details.