Catalog PyPI
Back to packageRELEASE DETAILS

0.3.2

PyPI

accordsync-fastapi

Accord sync server for FastAPI: router, settings and CLI.

crdtlocal-firstoffline-firstsync
Published8 Oct 2026
Direct dependencies2
Transitive dependenciesNot calculated

README

Version 0.3.2 documentation

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

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 2

Native requirements
2 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
accordsync-server
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
accordsync-server<0.4,>=0.3runtime
fastapi
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
fastapi>=0.115runtime

Distribution files

2 collected
accordsync_fastapi-0.3.2-py3-none-any.whl

bdist_wheel · 9.48 KB · Python py3

Source file
accordsync_fastapi-0.3.2.tar.gz

sdist · 9.24 KB · Python source

Source file

Repository

PENDING
crossben/accordsync-python

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:00 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:c735ce027bfe645c8bb3aae024f068a3fd642e3cff8f8e32adce05bf9153d5e1

Other collected versions

View all collected versions →