Skip to content

Longwei Documentation

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

Upgrading from 1.x?

longwei 2.0 contains breaking changes. See the upgrade guide for the full list and migration steps.

Quick start

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())

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