Home
Softono
apkit

apkit

Open source MIT Python
15
Stars
2
Forks
5
Issues
1
Watchers
1 month
Last Commit

About apkit

Powerful Toolkit for ActivityPub Implementations.

Platforms

Web Self-hosted

Languages

Python

apkit

Powerful Toolkit for ActivityPub Implementations.

Test Package version pre-commit.ci status Ask DeepWiki


Documentation: https://fedi-libs.github.io/apkit

Source Code: https://github.com/fedi-libs/apkit


[!WARNING] apkit is not stable. API changes with no regard for backward compatibility and new releases are sometimes made at short intervals.

apkit is a modern, fast, and powerful toolkit for building ActivityPub-based applications with Python, based on standard Python type hints.

The key features are:

  • FastAPI-based Server: Build high-performance, production-ready ActivityPub servers with the power and simplicity of FastAPI.
  • Async Client: Interact with other Fediverse servers using a modern async HTTP client.
  • Built-in Helpers: Simplified setup for Webfinger, NodeInfo, HTTP Signatures, and other Fediverse protocols.
  • Extensible: Designed to be flexible and easy to extend for your own custom ActivityPub logic.

Requirements

  • Python 3.12+
  • FastAPI for the server part.
  • apmodel for ActivityPub models.
  • apsig for HTTP Signatures.

Installation

pip install apkit

To include the server components (based on FastAPI), install with the server extra:

pip install "apkit[server]"

Example

Create a simple ActivityPub actor and serve it:

from apkit.models import Person
from apkit.server.app import ActivityPubServer
from apkit.server.responses import ActivityResponse

app = ActivityPubServer()

HOST = "example.com"

actor = Person(
    id=f"https://{HOST}/actor",
    name="apkit Demo",
    preferredUsername="demo",
    inbox=f"https://{HOST}/inbox",
)

@app.get("/actor")
async def get_actor():
    return ActivityResponse(actor)

Run the server with uvicorn:

$ uvicorn main:app