Get started for free
Database and API-builderBack-end scenariosWeb-page builderIntegrations
Why Directual
For developersFor product ownersFor freelancers and agenciesFor startups
PricingBlogMerchAcademyDocumentationFacebook group
Terms of servicePrivacy policy
Directual Academy
Further steps

Advanced techniques for API-builder

← Back to the list of tutorials

The Directual API-builder provides lots of additional configure options which are really useful for professional front-end developers. Let’s take a look at them!

Paging for GET-requests

The Directual database can store millions of objects, so it probably wouldn’t be a very efficient solution to grab them all from one request because that would be very time-consuming. The best, and most common practice to achieve that is to organise paging or dynamic content loading at the front-end.

For that, Directual supports special parameters pageSize that’s how many objects you want in the response, and ‘page’, which is simply the number of the page you’ve requested.

Dynamic sorting for GET-requests

We looked at sorting settings in "The basics" tutorial but sometime, you’ll need dynamic sorting. For example, if a user sets up sorting in the app interface. To handle that Directual supports special parameters in GET-requests. The parameter is called sort. The value is a combination of a field’s system name and a sorting order. We can use several sorting fields, one by one.

Custom filtering parameters for GET-requests

A GET-request can contain any number of custom parameters and, by composing filtering conditionals, we can include these parameters by typing {{HttpRequest.parameter_system_name}}.

Advanced filtering for GET-requests

In some cases, a developer needs to set up rather complex filtering. Simple lists of logical ‘AND’ and logical ‘OR’ are not enough. We need to combine different expressions. We can switch the conditional editor to coding-mode and describe any filtering logic in JSON-format. Like this.

You’ll find more detailed examples in the documentation.

Fields validation for POST-requests

It’s good practice for the API-layer to validate data on-the-go and respond with an exception if validation fails. The rules for each field from the security layer can be configured in api-endpoint settings. Note that if we try to POST a wrong object, we’ll see an exception in response.

Synchronic scenarios for POST-requests

A regular POST-request sends for an object and in response receives the status and the object. If there are scenarios that process all new objects of a certain type, they will normally run independently after the request has been received.

But there is another option. We can include a scenario (or a few of them) in the “running synchronically” list for our request. In this case the response will be sent AFTER the sync-mode-scenario has been completed.

It works like this:

  • We send an object;
  • It passes the validation rules (if there are any);
  • The synchronical scenario is triggered;
  • The scenario is completed and the object probably gets modified;
  • Directual sends a response, which includes the object (or to be precise—its fields that are allowed for reading);
  • This is a great mechanism for front-end development, but you should be aware that scenario running in synch mode consumes several times more resources! So try not to make your scenarios too complicated.

Cross-Origin Resource Sharing CORS

If a developer needs to request the API-endpoint from different domains, the cross-origin resource sharing option should be ON.

← Back to the list of tutorials

Have questions? Visit our facebook group.

Give Directual a try

Directual is the only no-code development platform which combines flexibility and scalability of traditional coding with modern visual-development approach.