Mock API, Script-to-API, and DB-to-API can be produced with a low-code method through the API Creator module of Apinizer Platform. In this article, I tried to explain what DB-to-API is, how it can be applied, the problems it solves and what are the conveniences.
Many APIs whose data we make available for other services, web applications, and mobile developments communicate to databases. With the DB-to-API feature of Apinizer, a REST API is produced instantly by designing endpoints that match the SQL statements of the database type.
Generally, low-code is the approach that allows you to turn an idea into an application, without requiring deep technical knowledge, by writing very little code. DB-to-API provides API generation from a database with the low-code method. If we talk about the advantages of this situation;
Let’s look at the API, whose job is to run the query in the relevant database, in comparison with the development scenario, code-first, and generation with the API design-first tool;
First, let’s take a step-by-step look at what we will do with the code-first approach, that is, creating an API by creating an application;
In addition to these steps, if there is feedback from the customer or the team using the API or a request to add a new feature during the maintenance or development process of the API, the above steps will be performed again.
If the security, monitoring, etc. of this API are desired, third-party dependencies will be added and development work will continue.
And most importantly, there should be someone(s) who have the technical knowledge to do these operations.
In such a scenario, an API, which runs SQL queries and returns the result, can take days to weeks to develop and go live. Consider this timespan for a scenario where the number of APIs increases and multiple teams develop APIs! 😱 Even a minor action such as a change of date format may take half a day for the developer to do and test it. The generation of the API description document (API Spec) can be skipped due to a focus on rapid code development or lack of experience. (Therefore, if there is no API documentation, how will these people make a call? 🙃). Frequently encountering such problems can put the system in spaghetti form or force it to find a workaround solution.
Additionally, this approach appears to be a more traditional solution. In today’s world where being agile is an important criterion, it should be taken into consideration that the API is quickly made available to stakeholders (time-to-market) or consumed and that the workflow is manageable.
Let’s look at the implementation of this scenario on Apinizer with the API design-first approach (These operations will take place through user-friendly interfaces and will be explained in detail later in the article.);
In this scenario, it takes much less time to develop and go live on the API. Making transactions through the interface rather than the application will reduce the risk of error. Operations such as updating the endpoints of the API can be implemented, tested, and deployed in seconds.
Then let’s start practicing the subject! During the application process, an API will be created based on the ’employees’ table on the MySQL-type ’employees’ database.
Apinizer interacts with the database via JDBC. Supported connections are for; Oracle Database, Microsoft SQL Server, PostgreSQL, MySQL, IBM DB2, SAP SYBASE, Apache Hive, Apache Impala (for now).
Apinizer allows multiple connections to be created for the databases it supports and uses connection pooling for them.
In below video, testing and building the connection to the Employees’ database is shown. This operation is done to determine which database the query will run on while creating the endpoint.
You can expand the database connection description according to your needs.
At this stage, we write the endpoint information and decide from which area of the request we will get the parameters in the query and which query to be run on the database. We also test the value returned from the query. In this section, attention should be paid to the API design (which HTTP method will be used? How should the URL design be?) according to the type of SQL statement.
Below, creating and testing the API named ‘Employees DB-to-API’ and the endpoint named ‘/employee/findByFirstNameAndLastName’ is shown:
List of all endpoints of Employees DB-to-API
Once the API is created, the Swagger and Open API types of API description documents can be accessed on the fly in JSON and YAML formats.
Another convenience provided by Apinizer is that API Proxy can be created within seconds and made available to other stakeholders.
Below, creating API Proxy and testing the endpoint from DB-to-API is shown:
API Proxy provides the following conveniences with less code;
➳ Click here to get more information about Apinizer API Gateway.
➳ Click here to try DB-to-API in Apinizer demo environment.
Input your search keywords and press Enter.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.