Metadata-Version: 2.4
Name: apkit
Version: 0.3.6
Summary: Powerful Toolkit for ActivityPub Implementations.
Project-URL: Repository, https://github.com/fedi-libs/apkit
Project-URL: Issues, https://github.com/fedi-libs/apkit/issues
Project-URL: Changelog, https://github.com/fedi-libs/apkit/blob/main/CHANGELOG.md
Author-email: AmaseCocoa <cocoa@amase.cc>
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: aiohttp>=3.12.15
Requires-Dist: apmodel>=0.5.1
Requires-Dist: apsig>=0.5.4
Requires-Dist: charset-normalizer>=3.4.3
Requires-Dist: httpcore[http2,socks]>=1.0.9
Requires-Dist: httpx>=0.28.1
Requires-Dist: requests>=2.32.5
Requires-Dist: types-requests>=2.32.4.20250913
Provides-Extra: redis
Requires-Dist: redis>=5.0.4; extra == 'redis'
Provides-Extra: server
Requires-Dist: fastapi>=0.116.1; extra == 'server'
Requires-Dist: uvicorn>=0.35.0; extra == 'server'
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://fedi-libs.github.io/apkit">
    <img src="https://raw.githubusercontent.com/fedi-libs/assets/refs/heads/main/png/apkit.png" alt="apkit" />
  </a>
</p>
<p align="center">
    <em>Powerful Toolkit for ActivityPub Implementations.</em>
</p>
<p align="center">
  <a href="https://github.com/fedi-libs/apkit/actions/workflows/publish.yml" target="_blank">
      <img src="https://github.com/fedi-libs/apkit/actions/workflows/publish.yml/badge.svg" alt="Test">
  </a>
  <a href="https://pypi.org/project/apkit" target="_blank">
      <img src="https://img.shields.io/pypi/v/apkit.svg" alt="Package version">
  </a>
  <a href="https://results.pre-commit.ci/latest/github/fedi-libs/apkit/main" target="_blank">
      <img src="https://results.pre-commit.ci/badge/github/fedi-libs/apkit/main.svg" alt="pre-commit.ci status">
  </a>
  <a href="https://deepwiki.com/fedi-libs/apkit" target="_blank">
      <img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
  </a>
</p>

---

**Documentation**: <a href="https://fedi-libs.github.io/apkit" target="_blank">https://fedi-libs.github.io/apkit</a>

**Source Code**: <a href="https://github.com/fedi-libs/apkit" target="_blank">https://github.com/fedi-libs/apkit</a>

---

> [!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](https://fastapi.tiangolo.com/) for the server part.
- [apmodel](https://github.com/fedi-libs/apmodel) for ActivityPub models.
- [apsig](https://github.com/fedi-libs/apsig) for HTTP Signatures.

## Installation

```bash
pip install apkit
```

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

```bash
pip install "apkit[server]"
```

## Example

Create a simple ActivityPub actor and serve it:

```python
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`:

```bash
$ uvicorn main:app
```
