Create a DataService Studio API in SQL mode
A DataService Studio API is created from data in your compute resources by configuring parameters. The API simplifies subsequent calls and reduces resource operation costs. SQL mode is suitable for queries that involve table joins and complex filtering, and it encapsulates the API logic using SQL code. This topic describes how to create a DataService Studio API in SQL mode.
Prerequisites
A compute resource has been created. For more information, see Create a compute resource.
An application has been created. For more information, see Create an application.
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 workspace, and click Asset Processing.In the navigation pane on the left, click the
icon and select API Development > DataService Studio API.In the upper-right corner of the DataService Studio API page, click Create API.
On the DataService Studio 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 computing resources
Select a compute resource.
NoteIf the target compute resource is not available in the list, click Go to Computing Resource Management to check its connectivity.
Source data table
Select a data table in the compute resource.
Service resource group
Select a service resource group.
NoteTesting and calling the API after it is published consumes resources from the resource group. Select a service resource group based on its specifications and usage.
Creation mode
Set Creation Mode to SQL Mode.
Enter the SQL code and click Syntax Check and Format. After no syntax or data format errors are reported, click Run.
NoteOnly SELECT statements are supported. For more information, see SQL syntax guide.
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.
Filter
(Optional) Turn on the Filter switch to show or hide the information module. For more information, see API result filters.
Test the API. Click Start Test and check 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.