bolinette-api
The Bolinette api extension: REST routes generated over a Service[Entity].
A controller declares the usual routes as empty stubs, typed by their own signature, and the extension replaces each one with a real route once it knows the entity. The payload and the response stay yours: they are the types written on the stub, so nothing is generated behind your back.
from pydantic import BaseModel
from bolinette.api import ApiController, autoroute
from bolinette.web import controller
from my_app.entities import Example
class ExamplePayload(BaseModel):
name: str
class ExampleResponse(BaseModel):
id: int
name: str
@controller("examples")
class ExampleController(ApiController[Example]):
@autoroute.get_all
async def get_all(self) -> list[ExampleResponse]: ...
@autoroute.create
async def create(self, payload: ExamplePayload) -> ExampleResponse: ...
Installation
$ pip install bolinette-api # or use your preferred package manager
Requirements
Bolinette-api requires Python 3.13 (or newer), and depends on bolinette, bolinette-data and bolinette-web. It is the package that binds the other two together, so it is only worth installing when an application has both entities and routes.
What the api extension does
- Six autoroutes —
get_all,get_one,create,update,patchanddelete, each mapping to aServicecall. - Paths from the primary key — a route addressing one entity follows the key columns, so a composite key becomes several segments.
- Your types, not generated ones — the stub's parameter is what the body is mapped onto, and its return type is what the entity is mapped to on the way out.
Anything the mapper has a protocol for works, which includes dataclasses and
TypedDicts alongside pydantic models. - The service without asking —
ApiController[Entity]receives itsService[Entity]and the mapper in its post_init. - Hand-written routes alongside — an
ApiControlleris aController, so a route the generator cannot express is written next to the stubs with the ordinary web decorators. - Sensible defaults —
createandupdateflush before mapping the response, so a generated primary key reaches the client, and a missing entity becomes a 404 carryingapi.entity.not_found.
blnt new project scaffolds an example entity and its controller when this extension is selected, which is the shortest way to see the whole shape at once.
License
Bolinette is released under the MIT license, see LICENSE.txt.
Metadata
Release files for bolinette-api 0.20.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 | |
|---|---|---|---|
| bolinette_api-0.20.0.tar.gz | 6.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bolinette_api-0.20.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.2 kB
Release files / bolinette_api-0.20.0.tar.gz
| Download URL | bolinette_api-0.20.0.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2358619aa93a1cc669c6f86fa01b70babc8eb9a5baaf7e985a89f71295af3c0c
|
|
BLAKE2b-256 checksum How to use checksums |
98435c1a2a8790bcc05095a885a206f39d254645acbaac2679f203d15d14868f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / bolinette_api-0.20.0-py3-none-any.whl
| Download URL | bolinette_api-0.20.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aaab2eff559a16d984b3b1a7e23943730bae8e1a4f174b863df63eb01b2aa8ac
|
|
BLAKE2b-256 checksum How to use checksums |
9a14c77db54562076c0401dee3c2b4ccee81a2db9fbfb88fd1cfa043efaa10d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.16 {"installer":{"name":"uv","version":"0.12.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|