CRUDL APIs
Application data can be exposed via CRUDL API in order to be provided to front end applications or sent to different databases.
Creating CRUDL API
General
- Root type – you can choose from two root sources:
- Entity/Codebook – select the source Entity or Codebook
- Service name – name of the API service (filled in automatically based on the Entity/Codebook name)
API
- Service url – url on which the api service will listen (filled in automatically based on the Entity/Codebook name)
- Authentication – authentication schema for the api; you can choose from three types:
- API key (technical user)
- Allowed technical users – technical users which have access to this api service
- User token (regular user)
- Custom Auth method
- Authentication method – you can choose from your custom Authentication methods
- API key (technical user)
- Data source – expression defining data source of api endpoint. Must return IQueryable of selected aspect or entity.
Example use with API key
public static ExampleEntity GetEntity(string api_address, string api_key, Guid entityId)
{
HttpClient client = new()
{
BaseAddress = new Uri(api_address),
DefaultRequestHeaders = {
{ "Accept", "application/json" },
{ "jv-api-key", api_key}
},
};
var response = client.GetAsync($"{entityId}").Result;
// Parse json ...
API Definition
Operations
- you can enable the following Operations: List, Read, Create, Update, Delete
List
in the left half of the tab select data that will be passed to the given GET request
there are more settings in the right half:
Query filters – allows you to create custom filter settings
Sorting – allows you to create custom sorting settings
Advanced settings
Enable Client evaluation mode for Database query – when enabled it forces the application to materialize all queried entities into memory and then do the projection on top of them. This allows you to invoke custom functions in expressions and deliver special functionality. On the other hand, this setting might cause slowness especially if you query (lazy-loaded) references on many items.
With this setting enabled, the projection (selecting the attributes) is performed by the application rather than the database. The sequence of actions is as follows:
Database Query (Excluding Projection)
->Projection (with lazy loading)
->Deserialization
->Send JSON
instead of:
Database Query (Including Projection)
->Deserialization
->Send JSON
Read
- in the left half of the tab select data that will be passed to the given GET request
- there are more settings in the right half:
- Advanced settings
- Enable Client evaluation mode for Database query – same as above
- Advanced settings
Create
- select data that will be passed to the given POST request
Update
- select data that will be passed to the given PUT request
Delete
- enable the DELETE request
Settings
This tab contains the settings you set when creating the CRUDL API. And one extra setting:
- Auto attribute camelCase – first character in attribute name will be generated as lower case (enabled by default)
Codebooks
Codebook Code
can be used as id
in API requests, namely in Create.