Introduction to substackR

Overview

The substackR package allows users to interact with the Substack API to retrieve various types of data from Substack publications. This includes fetching the latest posts, top posts, searching for specific content, and retrieving individual posts by their slug.

Installation

You can install the package from GitHub using the following command:

# install.packages("remotes")
remotes::install_github("posocap/substackR")

Setting Up Your API Key

Before using the package, you need to set your Substack API key:

library(substackR)
set_substack_key("YOUR_API_KEY")

Fetching Latest Posts

To fetch the latest posts from a Substack publication, use the get_substack_latest function:

latest_posts <- get_substack_latest("posocap.substack.com", limit = 5)
print(latest_posts)

Fetching Top Posts

You can also retrieve the most popular posts:

top_posts <- get_substack_top("posocap.substack.com", limit = 5)
print(top_posts)

Searching Posts

To search for specific posts, use the get_substack_search function:

search_results <- get_substack_search("posocap.substack.com", query = "economics", limit = 5)
print(search_results)

Fetching a Single Post

To get a single post by its slug:

single_post <- get_substack_post("posocap.substack.com", slug = "your-post-slug")
print(single_post)

Conclusion

The substackR package provides a simple and effective way to access Substack data, making it easier for developers and researchers to work with content from Substack publications.