- API Client makes a request to an endpoint in the DB-2-API on Apinizer.
- Apinizer sends this request to the database, and the query belonging to the relevant endpoint is executed on the database.
- The response to the relevant query from the database comes to Apinizer.
- Apinizer sends the response to API Client.

1
Establishing database connection
Defining MySQL database connection in Apinizer.
2
Creating endpoints
Defining endpoints for GET, POST, PUT, DELETE operations.
3
Converting to API Proxy
Converting DB-2-API to API Proxy format.
4
Testing
Testing the created endpoints.
Establishing Database Connection
Select the Database expression under the Connection Management menu.
Since no database connection has been made before, this page appears empty. Click the Create button in the top right corner.

- Write the name of the database you are connecting to with the Name field.
- A description is made for the connection to be created with the Description field.
- Select the type of connection to be created with Database Type.
- Write the address of the database to be connected to with the JDBC URL field. An example connection string is also in the input field.
- Enter the username required for the database to be connected to with the Username field, and write the password information to be entered during connection in the Password field.
- For information about other fields besides these fields, you can look at the database connection page.


Creating DB-2-API
After the database connection is established, proceed to the DB-2-API creation stage. Select the DB-2-API option under the API Creator menu in the Development menu.
After selecting the DB-2-API option, an empty page appears on the screen. This is because no DB-2-API has been created before.


- The Name field must give a name to the DB-2-API. This field cannot be left empty.
- A description can be added as desired.

- Select the methods (GET,POST,DELETE,PUT, etc.) of the endpoint to be created with the HTTP Method field.
- Enter the name of the endpoint in the Name/URL field.
- A description related to the endpoint can be added in the Description field.
- Select the database to be connected to with the Connection Pool Definition field.
- Specify how many seconds the created query will timeout with the Timeout field.
- Select what type the SQL query to be written will be created with the Type of SQL Statement expression.
- Enter the SQL query to be written in the Enter SQL Statement field.

GET Endpoint: /getSalariesByEmpNo
First, an endpoint named /getSalariesByEmpNo will be created. For this endpoint to be usable, a parameter of Query type must be sent. The fields to be used in this endpoint have been entered in the sections explained one by one above.

- Data Type: integer
- Repetition Type: Single (because it contains a single field)
- Parameter Type: Query
- Test Value: Write the value to be tested to get an example response
PUT Endpoint: /updateDepartmentByDeptNo
The second endpoint to be created is the endpoint named /updateDepartmentByDeptNo. For this, it is necessary to click the Add button in the red rectangle as seen in the image below.


DELETE Endpoint: /deleteSalariesByEmpNo
The last endpoint to be created is the endpoint named /deleteSalariesByEmpNo. To add this endpoint, click the Add button in the red rectangle in the image below and create the endpoint from the screen that opens on the right.



Creating API Proxy from DB-2-API
On this page:- Give a name to the API Proxy to be created from DB-2-API in the Name field.
- Write the /db2api path expression in the Relative Path expression. This address will be the address where the API Proxy will be opened to the outside.


Testing the API Proxy
Here, click the Deploy button in the red rectangle above and in the image to deploy the API Proxy.
1
GET endpoint test
Select the endpoint named /getSalariesByEmpNo and click the Test Endpoint button.
Enter the value “10005” as the Query parameter and obtain the response in the red rectangle.


2
PUT endpoint test
After testing this endpoint, select the second endpoint named /updateDepartmentByDeptNo for testing.Click the Test Endpoint button.
Since this endpoint requests two pieces of data in the Body, they are given in key/value format.When the Send button is clicked, the response in the red rectangle is obtained as a response.


3
DELETE endpoint test
Finally, select the endpoint named /deleteSalariesByEmpNo for testing.Click the Test Endpoint button.
This endpoint takes a parameter of Query type. Enter the value “10005” and when you click the Send button, the response obtained is in the red rectangle.



