MyNixOS website logo
Description

Access Substack Data via API.

An interface to access data from Substack publications via API. Users can fetch the latest, top, search for specific posts, or retrieve a single post by its slug. This functionality is useful for developers and researchers looking to analyze Substack content or integrate it into their applications. For more information, visit the API documentation at <https://substackapi.dev/introduction>.

substackR

R-CMD-check

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.

Installation

From CRAN:

install.packages("substackR")

Development version from GitHub:

# install.packages("pak")   # if needed
pak::pak("posocap/substackR")

Authentication

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.

Main Functions

get_substack_latest()

Fetches the latest posts.

latest_posts <- get_substack_latest(
  publication_url = "posocap.substack.com",
  limit           = 10,
  offset          = 0
)

Returns a data frame with columns:

  • slug
  • url
  • title
  • description
  • excerpt
  • body_html
  • reading_time_minutes
  • audio_url
  • date
  • likes
  • paywall
  • cover_image
  • cover_image_color_palette
  • author
  • author_image

get_substack_top()

Fetches the top (most liked) posts.

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

get_substack_search()

Searches posts by keyword.

search_results <- get_substack_search(
  publication_url = "posocap.substack.com",
  query           = "data science",
  limit           = 20
)

get_substack_post()

Retrieves a single post by slug.

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

Error Handling

  • Missing API key → error asking you to run set_substack_key().
  • HTTP errors (4xx, 5xx, rate limits) → cli::cli_abort() with status code and message.
  • JSON parsing issues → warning + empty data frame.

Contributing

  1. Fork the repo
  2. Create a branch (e.g. feature/xyz)
  3. Install dependencies:
    devtools::install_deps(dependencies = TRUE)
    
  4. Run tests:
    devtools::test()
    
  5. Submit a pull request.

License

MIT © Posocap.com
See LICENSE for details.

Metadata

Version

0.1.15

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows