Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

datasette-plugin-router

PyPI Changelog Tests License

WIP router for Datasette plugins

Datasette plugins that have a lot of custom API endpoints can get tiresome to write by hand. datasette-plugin-router aims to be a small Python library that adds a FastAPI-like API for defining custom Datasette plugin endpoints.

  • Define routes with familiar GET/POST decorators
  • Define Pydantic-backed input/output schemas on JSON endpoints
  • register_routes() compatability
  • export to OpenAPI schema for codegen'ing clients

Sample usage:

from datasette import Response, hookimpl
from datasette_plugin_router import Router, Body
from pydantic import BaseModel

router = Router()

class Input(BaseModel):
    id: int
    name: str

class Output(BaseModel):
    id_negative: int
    name_upper: str

@router.POST(r"/-/demo1$", output=Output)
async def demo1(params: Body[Input]) -> Output:
    output = Output(
        id_negative=-1 * params.id,
        name_upper=params.name.upper(),
    )
    return Response.json(output.model_dump())


@router.GET(r"/-/hello/(?P<name>.*)$")
async def hello(name: str):
    return Response.html(f"<h1>Hello, {name}!</h1>")


@hookimpl
def register_routes():
    return router.routes()

Request body validation errors

If a Body()-injected request body fails Pydantic validation — including an empty body or malformed JSON — the router returns a 400 instead of a 500:

{
  "error": "id: Input should be a valid integer, unable to parse string as an integer",
  "errors": [{"type": "int_parsing", "loc": ["id"], "msg": "..."}]
}
  • error joins each field error as "<loc>: <msg>" (just <msg> when there is no location, e.g. malformed JSON) with "; ".
  • errors is ValidationError.errors() minus the url/ctx/input fields.
  • Messages are Pydantic's msg verbatim, so custom validator messages pass through.

Metadata

Release files for datasette-plugin-router 0.0.1a6

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

Source distribution (sdist)

Source distribution for datasette-plugin-router 0.0.1a6
File Size Uploaded
datasette_plugin_router-0.0.1a6.tar.gz 12.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datasette-plugin-router 0.0.1a6
File Interpreter ABI Platform
datasette_plugin_router-0.0.1a6-py3-none-any.whl Python 3 none any Details

Total release size: 26.6 kB

Release files / datasette_plugin_router-0.0.1a6.tar.gz

Download URL datasette_plugin_router-0.0.1a6.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6d6601f260d969a91fb6b66f587f2eb0daa1a2f89f8b15a46ad35fb08a51aae1
BLAKE2b-256 checksum
How to use checksums
130ed789da73a00aaecba667c53736a1354865de5903a4cb125ac284ffc74c5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 12, 2026.

Transparency log

Release files / datasette_plugin_router-0.0.1a6-py3-none-any.whl

Download URL datasette_plugin_router-0.0.1a6-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1eecc13f35761ee093bca356aab26c66218b310c9a1f0a0a91ab6a76d8166020
BLAKE2b-256 checksum
How to use checksums
e842feec94b69cb22977b94666a41ad9f1d63476a9f0a2c57b0bfc75432bf239
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 12, 2026.

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