Metadata-Version: 2.1
Name: substack-api
Version: 0.1.0
Summary: unofficial python wrapper for collecting substack data
License: MIT
Author: NHagar
Author-email: nicholasrhagar@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: beautifulsoup4 (>=4.12.3,<5.0.0)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Description-Content-Type: text/markdown

# Substack-api

**An unofficial Python wrapper around Substack's API.**

I developed this package as a lightweight tool to help researchers collect data about Substack newsletters, and to help writers archive their work off-platform. This is not a tool designed for bulk text extraction/web scraping. It supports the following functionality:

* Download full JSON metadata about newsletters by category
* Download full JSON metadata about posts by newsletter
* Download text of individual, publicly-available posts
* List newsletter categories

## Installation

`pip install substack-api`

## Usage

```from substack_api import substack_api```

List all categories on Substack:

```
substack_api.list_all_categories()
```

Get metadata for the first 2 pages of Technology newsletters:

```
substack_api.get_newsletters_in_category(4, start_page=0, end_page=2)
```

Get post metadata for the most recent 30 posts from a newsletter:

```
substack_api.get_newsletter_post_metadata("platformer", start_offset=0, end_offset=30)
```

Get post contents (HTML only) from one newsletter post:

```
substack_api.get_post_contents("platformer", "how-a-single-engineer-brought-down", html_only=True)
```
