Create a DataService Studio API in SQL mode

Updated at:

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

Procedure

  1. Log on to the Data Resource Platform console.

  2. In the upper-left corner of the page, click the 导航图标 icon and select Collaboration.

  3. In the top menu bar, click the 选择工作组 icon, select the target workspace, and click Asset Processing.

  4. In the navigation pane on the left, click the API icon and select API Development > DataService Studio API.

  5. In the upper-right corner of the DataService Studio API page, click Create API.

  6. On the DataService Studio API-Create page, configure the API.

    1. 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.

    2. In the Parameter Settings section, configure the API parameters.

      Parameter

      Description

      Cloud computing resources

      Select a compute resource.

      Note

      If 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.

      Note

      Testing 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

      1. Set Creation Mode to SQL Mode.

      2. Enter the SQL code and click Syntax Check and Format. After no syntax or data format errors are reported, click Run.

        Note

        Only 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.

    3. Test the API. Click Start Test and check the returned content.

    4. 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.

  7. 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
  • When you edit the cloud compute resource in the API parameter settings, check if any fields in the current table are the same as the fields in the table used before editing. If they are the same, your edits may not take effect.

  • Changing the service resource group affects the API Path.

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

  • Single deletion: In the Actions column of the API resource list, choose More > Delete. In the Delete dialog box, click OK.

  • Batch deletion: In the API resource list, select the APIs to delete and click Batch Delete below the list. In the Batch Delete dialog box, click OK.

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.