Generate full REST APIs from your entities automatically - without writing repetitive code.
📦 Example: Web.DatabaseAsApi
Expose a complete CRUD for an entity with just one line:
type
[Table('products')]
TProduct = class
public
[PK, AutoInc] property Id: Integer;
property Name: string;
property Price: Double;
end;
// Configure in the pipeline
App.Configure(procedure(App: IApplicationBuilder)
begin
// Maps GET, POST, PUT, DELETE to /api/products
TDataApiHandler<TProduct>.Map(App, '/api/products');
end);| Method | URL | Description |
|---|---|---|
| GET | /api/products |
List all (supports pagination/filters) |
| GET | /api/products/{id} |
Find by unique ID |
| POST | /api/products |
Create new record |
| PUT | /api/products/{id} |
Update existing record |
| DELETE | /api/products/{id} |
Delete record |
Use query parameters to control returned data:
?page=1&pageSize=20?orderBy=Name&desc=true
Filter records directly via URL:
?Name=Keyboard(Exact match)?Price_gt=100(Price greater than 100)?Status_in=Active,Pending(IN filter)
You can restrict which operations are available:
TDataApiHandler<TProduct>.Map(App, '/api/products',
procedure(Options: TDataApiOptions)
begin
Options.AllowedOperations := [ToRead, ToCreate]; // Read and Create only
Options.RequireAuthorization := True; // Requires JWT
end);Dext Database as API integrates the TEntityIdResolver to automatically detect and process the type of your primary key ([PK]). It converts the {id} placeholder in the URL back to the actual entity type transparently.
This allows the use of modern types like TUUID or custom identifiers without any extra configuration:
type
[Table('system_logs')]
TSystemLog = class
public
[PK] property Id: TUUID;
property Message: string;
end;
// The route /api/logs/{id} will accept UUID strings (e.g., /api/logs/550e8400-e29b...)
TDataApiHandler<TSystemLog>.Map(App, '/api/logs');