Ana içeriğe geç

Creating API from Database with API Creator

It supports the following operations:

Native SQL Statements

Supports SELECT, INSERT, UPDATE, DELETE, PROCEDURE, BATCH INSERT, TRUNCATE operations.

NoSQL Operations

Provides FIND operation type support.

Stored Procedure

Provides Stored Procedure calling support.

Cursor Support

Can return cursor result.

Batch Operations

Provides batch operation support.

CRUD Operations

Supports all CRUD operations.

Creating New DB-2-API

Go to DB-2-API Page from Menu

Development → API Creator → DB-2-API item is selected in the main menu.

Create New API

The +Create button at the top right of the opened interface is clicked.

DB-2-API Create button
Fill API Information

Required fields for the new API to be created are filled and the →Save and Next button at the top right is clicked, starting the API creation process.

Filling DB-2-API information

Endpoint Creation

Add Endpoint

Method/Endpoint is added to the API by clicking the Add button on the screen that appears.

Add endpoint
Fill Endpoint Information

Fields in the Method/Endpoint definition screen are filled and the Save button is clicked.

Endpoint definition

Fields used to create endpoints are explained below, categorized:

Basic Information
HTTP Method

Field: HTTP Method

HTTP Method is selected for REST APIs: GET, POST, PUT, HEAD, OPTIONS, DELETE, PATCH, TRACE, ALL

Name/URL

Field: Name/URL

The name given to Method/Endpoint by the user. This name appears in interfaces.

Description

Field: Description

Definition information of Method/Endpoint.

Database Connection
Connection Pool

Field: Connection Pool Description

Information about the Database connection where queries will be executed.

Query Timeout

Field: Timeout

Timeout value in seconds for query execution.

SQL Operations
SQL Statement Type

Field: Type of SQL Statement

SQL Statement type information: SELECT, UPDATE, INSERT, DELETE, PROCEDURE, TRUNCATE, BATCH INSERT

SQL Statement

Field: SQL

The SQL statement to be executed. Parameters must be written with a colon (:) prefix without spaces to be definable.

Example query:

select * from employees where first_name = :fName

Here :fName is a parameter and is sent by the user making a request to the API.

ipucu

You can check the correctness of your query by entering example values for the parameter and clicking the Try It button.

NoSQL Operations
Operation Type

Field: Operation Type

NoSQL operation type information: FIND

Query

Field: Query

The query to be executed. Parameters are enclosed in double curly braces to be definable.

Example query:

{ username: {{username}} }

Here {{username}} is a parameter and is sent by the user making a request to the API.

ipucu

You can check the correctness of your query by entering example values for the parameter and clicking the Try It button.

Parameters
Parameters

Field: Parameters

If there is a parameter like :fName in your SQL Query, the Parameters table opens. Here the parameter's:

  • Data Type
  • Format
  • Repetition Type
  • Parameter Type
  • Example Values

are entered.

bilgi

Then by clicking the Try button, the "Response Message Example" comes according to this data.

Testing SQL

It may be desired to see what result will be obtained when a request is sent to the endpoint. If the query to be executed for the endpoint has parameters, test data (Test Value) is entered and the Try It button is pressed.

The template returned as the test result is the Response object that is stable in Apinizer. If there are multiple records matching the query, only the first record is given in the example response.

Testing SQL
bilgi

If a null value is desired to be sent for testing, it is sufficient to write null as the parameter.

Creating API Proxy from DB-2-API

When there is at least one Method/Endpoint, an API Proxy is created for DB-2-API by clicking the Create API Proxy button.

uyarı

At least one Method/Endpoint must exist to create an API Proxy from DB-2-API.

The API Proxy is created by entering the required fields for the API Proxy on the screen that appears and clicking the Save button.

API Proxy creation

After this step, what can be done is exactly the same as the API Proxy document. You can refer to the API Proxy Creation page for details.

bilgi

You can create multiple API Proxies from one DB-2-API.

Deploy/Redeploy

To view and manage API Proxies in DB-2-API, click the Manage API Proxies link and they are viewed and managed from the opened window. In the opened window, Deploy/Undeploy and Redeploy operations for API Proxies created with DB-2-API are performed in this section.

To deploy the API Proxy, click the Manage API Proxies link and press the deploy icon.

API Proxy management

After the above operation, confirmation is required. Information about the deployment operation is created and the (Deploy) Deploy button is clicked.

Deploy screen

When a new Method/Endpoint is added to DB-2-API or one of the existing Method/Endpoints is updated, all API Proxies must be redeployed.

When you add a new Method/Endpoint or update an existing Method/Endpoint, a notification like the following will appear.

Redeploy notification

By saying Redeploy Required, changes are applied to API Proxies.

Redeploy screen

After the above operation, confirmation is required. Information about the redeployment operation is created and the (Redeploy) Redeploy button is clicked.

Redeploy confirmation screen

From the DB-2-API page, go to the API Proxy by clicking the link in the API Proxy's name.

Link from DB-2-API to API Proxy

Similarly, to go to the DB-2-API page from the API Proxy page, go by clicking the DB-2-API name in the API Proxy as shown below.

Link from API Proxy to DB-2-API

DB-2-API Deletion

When a DB-2-API is deleted, all API Proxies connected to it are first removed (Undeploy) and then deleted.