apkit
Powerful Toolkit for ActivityPub Implementations.
Documentation: https://fedi-libs.github.io/apkit
Source Code: https://github.com/fedi-libs/apkit
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 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
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
License¶
This project is licensed under the terms of the MIT license.