Longwei is a lightweight Python client library for ActivityPub-compatible servers, designed for apps that need to connect to federated social instances.
  • Python 99.7%
  • Just 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Marvin8 e284248b6a
All checks were successful
/ pr-review (push) Has been skipped
/ gitleaks (push) Successful in 17s
/ pr-review (release) Has been skipped
/ gitleaks (release) Successful in 14s
/ checks (push) Successful in 3m41s
/ publish (push) Has been skipped
/ checks (release) Successful in 3m54s
/ deploy-docs (release) Has been skipped
/ publish (release) Successful in 27s
/ deploy-docs (push) Successful in 1m9s
🔧 bump: version 2.0.3 → 2.1.0
2026-08-05 17:49:49 +10:00
.forgejo/workflows 📝 Update source references to forge.marvin8.zone 2026-08-05 14:10:28 +10:00
docs 🐛 Bump pymdown-extensions constraint for PYSEC-2026-3609 2026-08-05 14:32:54 +10:00
src/longwei ♻️ Enforce keyword-only args for optional parameters 2026-08-05 16:05:10 +10:00
tests 🔧 align scaffolding configs (ruff, gitleaks, editorconfig) 2026-07-20 10:09:36 +10:00
.editorconfig 🔧 align scaffolding configs (ruff, gitleaks, editorconfig) 2026-07-20 10:09:36 +10:00
.gitignore 🔧 gitignore docs/superpowers/ and .superpowers/ 2026-07-08 07:17:47 +10:00
.gitleaks.toml 📝 restore gitleaks allowlist comments 2026-07-20 10:41:04 +10:00
.pre-commit-config.yaml 📝 create AGENTS.md and symlink CLAUDE.md 2026-07-20 10:09:25 +10:00
.pylintrc Initial commit after fork and rename from minimal_activitypub to 2026-04-01 18:28:55 +10:00
.python-version Initial commit after fork and rename from minimal_activitypub to 2026-04-01 18:28:55 +10:00
AGENTS.md 📝 Update source references to forge.marvin8.zone 2026-08-05 14:10:28 +10:00
AI-DECLARATION.md 📝 note human origins in AI-DECLARATION.md 2026-07-20 10:48:42 +10:00
CHANGELOG.md docs: update changelog for 2.1.0 2026-08-05 17:49:46 +10:00
CLAUDE.md 📝 create AGENTS.md and symlink CLAUDE.md 2026-07-20 10:09:25 +10:00
docs_hooks.py 🔧 fix imports on docs_hook.py 2026-08-05 17:40:08 +10:00
justfile 📝 Update source references to forge.marvin8.zone 2026-08-05 14:10:28 +10:00
LICENSE.md Initial commit after fork and rename from minimal_activitypub to 2026-04-01 18:28:55 +10:00
mkdocs.yml 📝 Update source references to forge.marvin8.zone 2026-08-05 14:10:28 +10:00
noxfile.py 👷 split out individual tasks 2026-06-08 14:37:38 +10:00
pylock.toml 🐛 Bump pymdown-extensions constraint for PYSEC-2026-3609 2026-08-05 14:32:54 +10:00
pyproject.toml 🔧 bump: version 2.0.3 → 2.1.0 2026-08-05 17:49:49 +10:00
README.md 📝 Update remaining docs links to longwei.marvin8.zone 2026-08-05 16:10:35 +10:00
Release-Notes.md 🔧 bump: version 2.0.3 → 2.1.0 2026-08-05 17:49:49 +10:00
Release-Notes.md.template 🔧 remove git-cliff; generate changelog from Release-Notes.md 2026-07-08 07:20:58 +10:00
ruff.toml 🔧 align scaffolding configs (ruff, gitleaks, editorconfig) 2026-07-20 10:09:36 +10:00
Security-Audit-Detail.md 🔧 update git workflow and reformat Security Audit for yilan 2026-05-15 14:23:46 +10:00
Security-Audit.md 🔧 update git workflow and reformat Security Audit for yilan 2026-05-15 14:23:46 +10:00
uv.lock 🔧 bump: version 2.0.3 → 2.1.0 2026-08-05 17:49:49 +10:00

longwei

Docs Repo CI Downloads uv_secure gitleaks AI Declaration pysentry complexipy Codestyle Version Wheel License: AGPL-3.0-or-later

Longwei is a minimal Python implementation of the ActivityPub client REST API used by Mastodon, Pleroma, GotoSocial, and snac. This implementation makes use of asyncio where appropriate. It is intended to be used as a library by other applications. No standalone functionality is provided.

All targeted Mastodon v1/v2 API endpoints are now implemented, covering accounts, timelines, statuses, notifications, lists, filters, polls, reports, discovery, and instance management. Admin, push notification, and proof endpoints are intentionally out of scope. Longwei is used by Fedinesia, Feed2Fedi, and FenLiu and Zhongli.

Quick start

pip install longwei
import asyncio
from longwei import APClient

async def main():
    async with await APClient.create(
        instance="mastodon.social",
        access_token="your_token",
    ) as ap:
        status = await ap.post_status("Hello, fediverse!")
        print(status.url)

asyncio.run(main())

API References

Status

longwei is a fork of minimal_activitypub. It is not a drop-in replacement. See the Upgrading guide for full migration instructions.

longwei 2.0 introduced additional breaking changes: the client= parameter has been removed from APClient and all auth methods, and the underlying HTTP library has changed from httpx to httpx2. See the upgrade guide for details.

Contributing

Issues and pull requests are welcome.

longwei is using pre-commit for code quality checks and uv for dependency management. Please install and use both pre-commit and uv if you'd like to contribute.

Documentation

The live documentation is at https://longwei.marvin8.zone/latest/

Built with MkDocs and the Material theme. To build and serve locally:

uv sync --group docs
mkdocs serve

Development

This project uses uv for dependency management and virtual environments. To set up the development environment:

# Create and activate virtual environment
uv venv
source .venv/bin/activate

# Install all dependencies including development and documentation groups
uv sync --all-groups

# Run tests
uv run nox

For more details on the development workflow, check the noxfile.py and .forgejo/ configuration files.

Licensing

longwei is licenced with the GNU Affero General Public License v3.0

Supporting longwei

There are a number of ways you can support longwei:

  • Create an issue with problems or ideas you have with/for longwei
  • You can buy me a coffee.
  • You can send me small change in Monero to the address below:

Monero donation address

8ADQkCya3orL178dADn4bnKuF1JuVGEG97HPRgmXgmZ2cZFSkWU9M2v7BssEGeTRNN2V5p6bSyHa83nrdu1XffDX3cnjKVu