DataService Studio in DataWorks lets you create APIs to expose data as a service, which applications can then consume through standard API calls. This topic shows you how to create, configure, and publish an API.
Prerequisites
-
You have created an exclusive resource group for DataService Studio or configured a quota for DataService Studio for a serverless resource group. You have also verified that your MaxCompute compute resources can connect to the resource group.
-
You have completed the Process data step and prepared a website user profile table.
Create a user profile API
Data synchronization and processing generates the ads_user_info_1d_${datasource-type} data table. You can then use the API feature in DataService Studio to expose this table to other services by generating an API with the Wizard Mode or Script Mode.
Step 1: Generate the user profile API
This example uses the API feature in DataService Studio.
-
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to DataService Studio.
-
Create an API service.
In DataService Studio, click the
icon and choose . In the Generate API dialog box, select Wizard Mode.NoteDataService Studio offers two methods for generating APIs: codeless UI and code editor. This example uses the codeless UI.
-
For more information about generating an API by using the codeless UI, see Generate an API from a data source (API Gateway).
-
For more information about generating an API by using the code editor, see Generate an API by using the code editor.
-
Step 2: Configure the user profile API
-
Configure the API details.
In the codeless UI, configure the following parameters for the StarRocks data source API. For more information, see Generate an API from a data source (API Gateway).
Module
Parameter
Description
Example
Table
Data Source Type
The type of your data source.
NoteDataService Studio APIs do not support Hive data sources. The supported types are listed in the drop-down list.
This topic uses a StarRocks data source as an example.
Data Source Name
The data source that you created.
Use the business data source
Doc_StarRocks_Storage_Compute_Tightly_01.Data Source Environment
-
Production Environment
-
Development Environment
Select Production Environment.
Data Table Name
The table that the API will use.
Select the
ads_user_info_1d_StarRockstable.Select Parameters
Pagination for Return Results
Whether you enable pagination affects how you set request parameters and response parameters for the API.
In the Resource Group section in the right-side navigation pane, you can set the Maximum Number of Data Records for a Single Request based on the resource group type. For more information, see Generate an API from a data source (API Gateway).
Pagination for Return Results is disabled.
Set as Req Param
The table fields to use as request parameters.
Set the partition field
dtas a Request Parameters.Set as Resp Param
The table fields to use as response parameters.
Set all fields of the
ads_user_info_1d_StarRockstable as Response Parameters.Sorting Fields
This parameter is optional. If you want to sort by a field, first select the field in the Select Parameters list.
Do not sort.
-
-
Configure the resource group for the service
After configuring the API in the codeless UI, click Resource Group for DataService Studio in the right-side navigation pane to configure its resources. The following table describes the parameters. For more information, see Configure a resource group for the API.
Module
Parameter
Description
Resource Group Type
Scheme
Exclusive Resource Group for DataService Studio.
Exclusive Resource Group for DataService Studio
You can select a serverless resource group (recommended) or an exclusive resource group for DataService Studio.
Important-
If you have purchased an exclusive resource group for DataService Studio, you can use it directly.
-
If no resource group is available, we recommend that you purchase a general-purpose serverless resource group. For more information, see Use a serverless resource group.
If the newly purchased serverless resource group is dimmed and cannot be selected when you configure the resource group, allocate a quota to the Data Services purpose for the resource group. For more information, see Allocate CU quotas to a task.
Environment Configuration
Timeout
The timeout period for the function, in milliseconds. Example: 30,000.
Maximum Number of Data Records for a Single Request
The maximum number of records that a single request can return. Example: 2,000.
-
Step 3: Test and publish the API
-
Test the API to verify that its response is correct. For more information, see Test an API.
-
After the configuration is complete, click the
Save icon, and then click the
Test icon to go to the API test page. -
In the Test APIs dialog box, enter values for the request parameters.
-
Click Start Test to test the API. For example, set the parameter name to
dt, the parameter type to STRING, the parameter location to QUERY, and the value to20240522. You can select Auto-save success response as example and click Test. If the test is successful, the Request Details section displays the executed SQL statement and logs. The response indicates success with an errCode of 0, an errMsg of 'success', and the query results in the data field.
-
-
Publishing an API means releasing it to API Gateway to generate a public endpoint. For more information, see Test, publish, and manage versions of an API.
-
After the API passes the test, click the
Submit icon on the API editing page. This action generates a new API version. Click the Version tab on the right to open the version management panel. In the version list, find the target version, such as v1, with a status of Publishable. -
Click Publish.
-
After the API is published, you can manage it on the Service Management page. Access this page by either clicking Service Management in the version management panel or navigating to . For more information, see Manage and maintain APIs.
-
Next steps
After publishing the API, you can authorize and call it. For more information, see Authorize an API and Call an API.