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.
/healthtouches 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_appin 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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| accordsync_fastapi-0.3.0.tar.gz | 9.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| accordsync_fastapi-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.2 kB
Release files / accordsync_fastapi-0.3.0.tar.gz
| Download URL | accordsync_fastapi-0.3.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bdd492b4f8df65ddeec857325e870b063934bf22fcd70f2179a509b70480225
|
|
BLAKE2b-256 checksum How to use checksums |
9b8fda72560562d4c9ccd451a402c418d2e2d1305e83561630814e9a950e6298
|
| 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 7, 2026.
Transparency logRelease files / accordsync_fastapi-0.3.0-py3-none-any.whl
| Download URL | accordsync_fastapi-0.3.0-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2999b7f7f64a55a7b3cacc3d497ae09cca32fe451f43d577b184e9addf06c611
|
|
BLAKE2b-256 checksum How to use checksums |
e0c34411e9ff9459b8287a2b8032f4e2f2eafb3897851044ad5c836da12fb4bb
|
| 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 7, 2026.
Transparency log