Create a Data Service API with the Codeless UI
Data Service APIs are generated from data in your cloud compute resources by configuring parameters. These APIs are easy to call and help reduce resource operation costs. The codeless UI is ideal for simple queries on a single table, allowing you to encapsulate an API through a graphical interface without writing code. This topic describes how to create a Data Service API using the codeless UI.
Prerequisites
-
A workgroup has been created. For more information, see Create a workgroup.
-
A cloud compute resource has been created. For more information, see Create a cloud compute resource.
-
An application has been created. For more information, see Create an application.
-
The cache table has been updated based on the physical table of the cloud compute resource. For more information, see View a physical table.
Background information
This topic uses an RDS for MySQL database as an example to demonstrate how to create an API.
Procedure
-
Log on to the Data Resource Platform console.
-
In the upper-left corner of the page, click the
icon and select Collaboration. -
In the top menu bar, click the
icon, select the target workgroup, and click Asset Processing. -
In the navigation pane on the left, click the
icon and choose API Development > Data Service API. -
In the upper-right corner of the Data Service API page, click Create API.
-
On the Data Service API - Create page, configure the API.
-
In the Basic Information section, set the basic information for the API.
Parameter
Description
API Name
Enter a custom name for the API.
Application
Select the application to which the API belongs. To create an application, click Add Application. For more information, see Create an application.
Service Protocol
Select the protocol type for the service.
API Path
The fixed path displayed when the API is called. A path is automatically generated by default.
Authentication Method
Two methods are available: Simple Authentication and Encrypted Authentication. For more information, see Authentication methods.
-
Simple Authentication: Suitable for API calls within a workgroup or in test scenarios. To make a call within a workgroup, use the AppCode of the application that the API belongs to.
-
Encrypted Authentication: Provides higher security. To call the API, calculate a signature using an encryption algorithm and include it in the request header. This method is suitable for calling shared APIs in application development scenarios.
Tags
Optional. Add application module tags to the API for statistical analysis.
To add a tag, click the plus sign (+). In the Add Tag dialog box, select the application and module tags, and then click Confirm.
Description
Required. Enter a custom description for the API.
-
-
In the Parameter Settings section, configure the API parameters.
Parameter
Description
Cloud Compute Resource
Select a cloud compute resource.
NoteIf the target cloud compute resource is not in the list, click Go to Cloud Compute Resource Management to check its connectivity.
Source Data Table
Select a data table from the cloud compute resource.
Service Resource Group
Select a service resource group.
NoteAPI testing and calls after publishing consume the resources of the resource group. Select a suitable service resource group based on its specifications and usage.
Creation Mode
Set Creation Mode to Codeless UI.
Response Parameters
-
In the Response Parameters section, select the fields to return.
-
Optional: In the Function column of the response parameters, click Add to add a function for a field. For information about the functions available for each data type, see the Functions for data types table.
Response Parameters (Custom Header)
Optional: In the Response Parameters (Custom Header) section, click Add Parameter. Then, enter the KEY, VALUE, and description for the header response parameter.
Request Parameters
Optional: In the Request Parameters section, click Add Parameter. Then, enter the field name, parameter name, condition, whether it is required, default value, and whether to filter during authorization.
NoteIf you set Filter during authorization to Yes, the authorization filter configuration item appears on the Authorization page. For more information, see Authorize an API.
Configuration Parameters
Optional: Turn on the Configuration Parameters switch to configure API parameters.
-
In the Configuration Parameters section, select Return Paged Results. You can then set the page index and page size for the results as needed.
NoteIf the result might contain more than 1,000 records, enable paging. Otherwise, a maximum of 1,000 records are returned.
-
Click Sort Field to add a sort field. This arranges the returned results based on the specified field and sort order.
-
Click Grouping Field to add a grouping field. This groups the returned results by the specified field.
Filter
Optional: Turn on the Filter switch to show or hide the information module. For more information, see API result filters.
Functions for data types
Data type
Function
Description
Numeric (INTEGER, DOUBLE, DECIMAL), BINARY, Time (TIME)
AVG
Average
COUNT
Count
MAX
Maximum value
MIN
Minimum value
SUM
Sum
VARIANCE
Variance
STDDEV
Standard deviation
String (STRING), BINARY, Time (TIME)
LOWER
Converts uppercase characters to lowercase.
UPPER
Converts lowercase characters to uppercase.
REPLACE
Replacement
SUBSTR
Extracts a substring.
LPAD
Pads the left side with a specified character.
RPAD
Pads the right side with a specified character.
LENGTH
String length.
Date (DATE, DATETIME), Time (TIME)
DAY
Day. Returns the day of the month for a date.
MONTH
Month. Returns the month for a date.
YEAR
Year. Returns the year for a date.
WEEKDAY
Weekday. Returns an integer that represents the day of the week.
CURRENT
Returns the current date.
-
-
Test the API. Click Start Test and verify the returned content.
-
Configure API throttling.
Parameter
Description
Maximum QPS for API
The maximum queries per second (QPS) for the API must be a positive integer no greater than 10,000. If Service Resource Group is set to Public Resource Group, the maximum QPS for the API can only be 1. For more information, see Parameters for API throttling.
Timeout Configuration
Select the response timeout period for a single API call. If Service Resource Group is set to Public Resource Group, the maximum response timeout period is 10s.
Enable Cache
Turn on the Enable Cache switch. API calls will then request the cache.
Cache Duration
After you enable the cache, you can manually set the cache expiration time. The maximum cache duration is 3,600 seconds.
-
-
After you configure the API parameters, click Save or Save and Publish.
The new API appears in the API resource list.
Related operations
|
Operation |
Description |
|
Edit an API |
In the API resource list, find the target API and click Edit in the Actions column. You can then modify the API on the editing page. Note
|
|
Copy an API |
In the Actions column of the API resource list, choose More > Copy. A new draft API is created in the API resource list. To modify the copied API, click Edit in its Actions column. |
|
Delete an API |
Note
You cannot delete published APIs. |
What to do next
After you create an API, you must publish it to make it available for use. For more information, see Publish an API.