Skip to main content

Python client library for ActivityPub-compatible servers

Project description

longwei

Docs Repo CI Downloads uv_secure gitleaks 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, and GotoSocial. 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.

So far Longwei only implements the ActivityPub API calls I need for my other projects Fedinesia, Feed2Fedi, FenLiu and Zhongli.

DO NOT expect a full or complete implementation of all ActivityPub API functionality.

Quick start

pip install longwei
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())

API References

Status

longwei is a fork of minimal_activitypub. The main breaking change from that package is the class rename: ActivityPubAPClient. See the Upgrading guide for migration instructions.

It is not a drop-in replacement. See the upgrading guide for migration instructions.

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://marvinsmastodontools.codeberg.page/longwei/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 .woodpecker/ 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

longwei-1.2.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

longwei-1.2.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file longwei-1.2.0.tar.gz.

File metadata

  • Download URL: longwei-1.2.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for longwei-1.2.0.tar.gz
Algorithm Hash digest
SHA256 de86d466dc781334c5df1f6595eeb8a2c1eea013869d22717f714a22f887d2be
MD5 6c3a5b2396bad0f692b02d90b87ff84a
BLAKE2b-256 cdc1d0932596f9f3986f970a192fd6e1e5d78dab8876a46238b22aa496df649f

See more details on using hashes here.

File details

Details for the file longwei-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: longwei-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for longwei-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 27309ab6de801a019cf4198d855890b4df9c49b33b679af31de0fcb3299cc934
MD5 0e8cb83265cb9ac66b7d87c070d76b8d
BLAKE2b-256 a54d3a9006100488f795c5ec44b61aa01d043e5fc25bb617f7ce420847c052ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page