Install and load
Run these commands in a Haybarn SQL session. The extension is available from the community repository.
INSTALL quackapi FROM community;
LOAD quackapi FROM community;
Using upstream DuckDB? Follow the maintainer’s installation instructions.
Usage example
JSON endpoint: the SELECT is the handler
-- JSON endpoint: the SELECT is the handler
CREATE ROUTE hello GET '/hello' AS SELECT 'world' AS msg;
-- Path params bind as $id; cast failure → FastAPI-shaped 422
CREATE ROUTE item GET '/items/:id' AS SELECT $id::INTEGER AS id;
-- HTML when the single output column is named html
CREATE ROUTE home GET '/' AS SELECT '<h1>quackapi</h1>' AS html;
-- Typed optional query param with constraint
CREATE ROUTE search GET '/search'
PARAM limit INTEGER DEFAULT 10 LE 100
AS
SELECT $q::VARCHAR AS q, $limit::INTEGER AS limit;
-- POST mutation (JSON body fields bind as $name / $age)
CREATE ROUTE create_user POST '/users' STATUS 201 AS
SELECT $name::VARCHAR AS name, $age::INTEGER AS age;
-- Serve (background threads; shell stays usable)
-- Optional: static_dir for unrouted GETs; cors_origins for browser CORS
SELECT * FROM quackapi_serve(8000);
-- curl http://127.0.0.1:8000/hello → [{"msg":"world"}]
-- curl http://127.0.0.1:8000/items/42 → [{"id":42}]
-- curl http://127.0.0.1:8000/items/abc → 422 detail[loc=path,id]
-- curl -X POST …/users -H 'Content-Type: application/json' -d '{"name":"a","age":3}'
SELECT * FROM quackapi_routes();
SELECT * FROM quackapi_stop(8000);
Provided by asubbarao. Not yet verified on Haybarn 2.0.0.
Sample data & setupAbout this extension
A FastAPI-class HTTP framework that lives inside DuckDB. Routes are DDL, handlers are SQL, and request validation is the database type system.
A conventional stack serializes at every hop (app server → workers → DB → PDF microservice). quackapi collapses that into one DuckDB process:
Project overview from the community descriptor.
Documentation and resources
Project and build details
- Repository
- asubbarao/quackapi
- License
- MIT
- Maintainers
- asubbarao
- Written in
- C++
- Build source
d5c0e6784fda- Build definition
- Community descriptor