Skip to main content

accordsync-fastapi

The Accord sync server for FastAPI: a router with POST /v1/push, GET /v1/pull and GET /health, and a CLI for migrations and compaction. All behaviour (auth, limits, CORS, rate limits, status codes, Accord-Protocol and Retry-After headers) comes from accordsync-server; this package only routes to it. Part of Accord.

Install

pip install accordsync-fastapi uvicorn

Use

from accordsync_core import define_schema, lww
from accordsync_server import Access, Auth, define_server
from accordsync_fastapi import accord_router
from fastapi import FastAPI

server = define_server(
    schema=define_schema({"note": {"owner": lww(), "title": lww()}}),
    scopes={"note": lambda r: [f"user:{r.fields.get('owner')}"]},
    access=lambda claims: Access(read=[f"user:{claims['sub']}"], write=[f"user:{claims['sub']}"]),
    auth=Auth.jwks("https://auth.example/.well-known/jwks.json", issuer="https://auth.example"),
)

app = FastAPI()
app.include_router(accord_router(server, database_url="postgresql://...", prefix="/sync"))

Given a definition, the router owns a psycopg pool (pool_size, default 20): it opens it in the application's lifespan and closes it at shutdown. You can instead pass an AccordServer(definition, pool) whose pool you manage; router_server(router) returns the server behind a router. Endpoints are plain def functions run in FastAPI's thread pool.

Run the migrations before serving:

ACCORD_DATABASE_URL=postgresql://... python -m accordsync_fastapi migrate

Compaction

With compaction.interval_ms > 0 in the definition (default one hour), the router's lifespan compacts on that interval in a background thread of each process. With several worker processes, pass schedule_compaction=False and run compaction from cron instead:

ACCORD_DATABASE_URL=postgresql://... python -m accordsync_fastapi compact --definition myapp.sync:server

Notes

  • Rate limits are per process (in memory). With several workers, each has its own buckets.
  • /health touches the database and answers 503 when it is unreachable.
  • Put TLS and request-size limits of your proxy in front as usual; the body limit (limits.max_body_bytes) is enforced while reading the body.
  • examples/fastapi_app in this repository serves the conformance profile and passes the shared server conformance suite (68/68). Its control API is for tests only (ACCORD_CONTROL=1).

Metadata

Release files for accordsync-fastapi 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for accordsync-fastapi 0.3.2
File Size Uploaded
accordsync_fastapi-0.3.2.tar.gz 9.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for accordsync-fastapi 0.3.2
File Interpreter ABI Platform
accordsync_fastapi-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.2 kB

Release files / accordsync_fastapi-0.3.2.tar.gz

Download URL accordsync_fastapi-0.3.2.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
63effa8995c8d1972624903716dd22faca153f0d4083e1d053990c7c9ede857e
BLAKE2b-256 checksum
How to use checksums
f83e637a62588b1993492d62e59b76a4c45d33426789592a6ef57fd9503c7ab3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / accordsync_fastapi-0.3.2-py3-none-any.whl

Download URL accordsync_fastapi-0.3.2-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
baa6e7802205b2cae26dc8de6f79a4d947e5997ad56fd809c9f6039cf996e952
BLAKE2b-256 checksum
How to use checksums
2f7fe7c16d2e3206f42209981f2e20c6d4c64396369b26e310509bfe24b222da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page