Skip to content

fedi-libs/apkit

Repository files navigation

apkit

Powerful Toolkit for ActivityPub Implementations.

Test Package version Supported Python versions


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

About

Powerful Toolkit for ActivityPub Implementations.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages