API
Custom API

Custom API

Radical generates standard CRUD APIs as soon as the API is enabled. However, in some cases, custom APIs might be required to introduce specific endpoints.

To build custom APIs, follow these steps:

  1. Go to the API tab.
  2. Click on "Add" in the sidebar.
  3. Select the schema for which the custom API has to be added.
  4. Enter the name of the API.
  5. Choose the newly selected API in the sidebar.

Visibility and Authentication

To control these options, check modify advanced options.

Request and Response Options

Request Options

On the request side, you can control the verb and path of the custom API.

  • Verb: Control whether the request is GET / POST / PUT / DELETE.
  • Path: This will be the path of the custom API. Example: /actions/returns.
  • Query Parameters: Add any custom query parameters (e.g., country). Example: /actions/returns?country=XX.
  • Headers: Include any custom headers to be consumed in the API.

Response Options

  • Status: Choose between 200 / 201 / 202.
  • Redirection URL: If 201 / 202 is specified, select the redirection action to a GET action on the existing resource.

Custom API Type

  • Type: Schema of the custom API. This can be different compared to the base schema where the custom API is added.

Example

Create registrations in vehicles:

/vehicles/{vehicleId}/registrations

  1. Create a Vehicle Schema.
  2. Enable CRUD for vehicles.
  3. Create a Registration Schema.
  4. Create a custom API in vehicles for creating registrations.
  5. Select the type as Registration.
  6. For PUT and POST verbs, select the fields to be exposed.
  7. Add query parameters and authorization (optional).
  8. Choose the response status.

This custom API will add the controller and service layer based on the visibility selection.