--- title: "Introduction to substackR" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Introduction to substackR} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` ## 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: ```{r eval=FALSE, include=TRUE} # 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: ```{r eval=FALSE, include=TRUE} 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: ```{r eval=FALSE, include=TRUE} latest_posts <- get_substack_latest("posocap.substack.com", limit = 5) print(latest_posts) ``` ## Fetching Top Posts You can also retrieve the most popular posts: ```{r eval=FALSE, include=TRUE} 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: ```{r eval=FALSE, include=TRUE} 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: ```{r eval=FALSE, include=TRUE} 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.