Skip to content

Longwei Documentation

Welcome to the Longwei documentation. Longwei is a minimal async Python client for ActivityPub servers (Mastodon, Pleroma, GotoSocial). It is the library powering Fedinesia, Feed2Fedi, and FenLiu and Zhongli.

Quick start

import asyncio
import httpx
from longwei import APClient

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

asyncio.run(main())

Documentation Sections

  • Getting Started — Installation, instantiation, and basic operations
  • Authentication — Password grant and OAuth authorization code flow
  • API Methods — Complete reference for all APClient methods
  • Posting — Statuses, media, scheduled posts, and content warnings
  • EnumsVisibility and SearchType
  • Data ModelsStatus, Account, and all nested Pydantic models
  • Error Handling — Exception hierarchy and handling patterns
  • Upgrading — Migration guide for earlier versions

Project Information

  • License: AGPL-3.0-or-later
  • Source Code: Codeberg
  • PyPI: longwei
  • Author: Marvin8