All Products
Search
Document Center

DataWorks:Use an API to provide data services

Last Updated:Mar 26, 2026

DataWorks DataService Studio lets you expose data tables as callable REST APIs, so downstream business applications can consume data without direct database access.

This tutorial walks you through creating and publishing a user profile API backed by a StarRocks data source (used as an example; other supported data source types are available).

How it works

  1. A processed data table (ads_user_info_1d_${Data source type}) exists in your data source.

  2. You create an API in DataService Studio, pointing it at the table and selecting which fields serve as request and response parameters.

  3. You test the API, then publish it to API Gateway. After publishing, an online calling address is generated that callers can invoke directly.

Prerequisites

Before you begin, ensure that you have:

Step 1: Create a user profile API

  1. Log on to the DataWorks console. In the top navigation bar, select the target region. In the left navigation pane, choose Data Analysis and Service > DataService Studio. Select your workspace from the drop-down list, then click Go to DataService Studio.

  2. In the Service Development pane, click the image icon and choose Create API > Generate API.

  3. In the Generate API dialog box, configure the parameters to create an API using the codeless UI.

DataService Studio supports two API creation methods: codeless UI and code editor. This tutorial uses the codeless UI. For the code editor method, see Create an API by using the code editor.

DataWorks allows you to create APIs in DataService Studio using either the codeless UI or code editor.

Step 2: Configure the user profile API

With the API created, configure the data table and resource group. For complete field descriptions, see Create an API by using the codeless UI.

Configure the data table

In the Select Table section:

  1. For Datasource Type, select StarRocks.

    API-based data services do not support Hive data sources.
  2. For Datasource Name, select the data source — in this example, Doc_StarRocks_Storage_Compute_Tightly_01.

  3. For Datasource Env., select Production.

  4. For Table Name, select the target table — in this example, ads_user_info_1d_StarRocks.

  5. In the Select Parameters section, configure the following:

    • Pagination for Return Results: Turn this off. When enabled, configure the Maximum Number of Data Records for a Single Request parameter on the Resource Group tab based on the resource group type that you specify.

    • Set as Req Param: Select the partition field dt as the request parameter.

    • Set as Resp Param: Select all fields in ads_user_info_1d_StarRocks as response parameters.

    • Sort field: Leave blank (optional).

Configure the resource group

Click Resource Group in the right navigation pane and configure the following settings. For details, see Configure a resource group for DataService Studio.

  1. Under Resource Group Type > Scheme, select Exclusive Resource Group for DataService Studio.

  2. Under Exclusive Resource Group for DataService Studio, select an exclusive resource group or a serverless resource group.

    Important

    If no resource group is available, purchase a serverless resource group. See Create and use a serverless resource group. If the serverless resource group is dimmed and cannot be selected, configure compute unit (CU) quotas for DataService Studio first. See Manage quotas.

  3. Under Environment Configuration, set Function Timeout to 30000 (milliseconds).

  4. Set Maximum Number of Data Records for a Single Request to 2000.

Step 3: Test and publish the API

Test the API

Before publishing, verify that the API returns the expected data.

  1. Click the image icon in the top toolbar to save the API.

  2. Click the image icon to open the Test APIs dialog box.

  3. Specify values for all request parameters, then click Test.

    image

For more information, see Test an API.

Publish the API

Once the test passes, publish the API to make it callable.

  1. Click the image icon in the top toolbar to submit the API. A version is generated. To view all versions, click Version in the right navigation pane.

    image

  2. In the Actions column of the version, click Publish. After the API is published to API Gateway, an online calling address is generated.

  3. To manage the published API, click Service Management in the Actions column, or navigate to Service Management in the top navigation bar and open the Published APIs tab on the Manage APIs page.

For more information, see Publish an API and Manage and maintain APIs.

What's next