Using the Decoupled approach, which is another method, the API development process that could take a long time can be facilitated and developed much faster with Drupal. The reasons why developers prefer this method, which is used to access content created with Drupal from external applications, can be listed as follows:;
In addition to easily creating APIs, the main advantages provided by Drupal include access control, caching, statistics, and user experience while creating content.
Drupal decoupled olarak kullanılacak drupal yapısı tasarlanmadan önce bu yapı ile oluşturmak istenen api yöntemi belirlenmelidir. SOAP, REST ve GraphQL olmak üzere daha bir çok yöntem bulunmaktadır.
If the API is desired to be developed using the REST method in Drupal 8, there is already a relevant module available along with the Serialization module. With the help of this module, API endpoints can be easily created using the view structure.
An API developed using the REST method can only output data in the way it is defined.
Indeed, in the scenario where data is retrieved from the "For Sale Cars" view, there may be a situation in the future where the phone number of the person selling the car is no longer needed. However, if direct modifications are made to the corresponding view, users who have not yet updated their applications may experience issues, leading to potential user loss as the existing application relies on the phone number data.
GraphQL, developed by Facebook, is a method developed to address this problem. With this method, the output data to be obtained is determined by the client. Thus, only the required data can be easily obtained in many applications or versions.
To develop a RESTful web service in Drupal 8 and above, the "RESTful Web Services" module, which comes pre-installed and awaits activation, should be installed. Before installing this module, make sure that the Serialization module is active.
Afterwards, a new View should be created under the "Structure" tab, and the desired path should be specified by activating the feature under the "Rest Export Settings" tab, as shown in the image above. (/api/v1/cars).
Once the "JSON" and/or "XML" option is selected in the View format settings, the API will be ready for use at the defined address. Thanks to the comprehensive features of Drupal views, the data provided by the created APIs can be easily enriched by associating them with other fields. Sorting, filtering, pagination, security control, and parameter-based results can be configured and customized in the View section.
Creating an API endpoint is that easy. Now, all that needs to be done is to enter content through Drupal's user-friendly administration panel.
In my next article, I will discuss how to quickly install "Bitnami Drupal 9" using Amazon Web Services Lightsail.
To stay updated with our articles, you can sign up for our mailing list using the form below and follow us on our social media accounts.