DataService Studio exposes processed data tables as REST APIs for other business applications. This tutorial walks you through creating, configuring, testing, and publishing an API that serves data from the ads_user_info_1d user profile table.
Prerequisites
-
You have purchased an exclusive resource group for DataService Studio or allocated a quota for DataService Studio to a serverless resource group. You must also ensure that the resource group is connected to a MaxCompute compute resource.
-
You have processed your data and generated the user profile table, as described in Process data.
Create a user profile API
After data synchronization and processing, the ads_user_info_1d table is ready. To expose it as an API, use the DataService Studio API feature to generate an API in Wizard Mode or Script Mode.
Step 1: Generate the user profile API
-
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.
On the DataService Studio page, click the
icon and choose . In the Generate API dialog box, select Wizard Mode to generate the API.NoteDataService Studio supports two modes for generating APIs: wizard mode and script mode.
-
For more information about wizard mode, see Generate an API from a data source (API Gateway).
-
For more information about script mode, see Generate an API in script mode.
-
Step 2: Configure the user profile API
-
Configure the API.
In wizard mode, configure the following parameters to create an API for your MaxCompute data source. For more information, see Generate an API from a data source (API Gateway).
Section
Parameter
Description
Example
Table
Data Source Type
Select the type of your data source.
NoteDataService Studio does not support Hive data sources. The available types are listed in the drop-down menu.
This tutorial uses a MaxCompute data source.
Data Source Name
Select your data source.
Select your business data source.
Data Source Environment
-
Production Environment
-
Development Environment
Select Production Environment.
Data Table Name
Select the table you want to expose through the API.
Select the
ads_user_info_1dtable.Select Parameters
Pagination for Return Results
Controls whether results are paginated. This setting affects the request and response parameters.
You can configure the maximum number of records per request in the service resource group settings. For more information, see Generate an API from a data source (API Gateway).
Turn off Pagination for Return Results.
Set as Req Param
Set one or more fields in the table as request parameters.
Set the
dtpartition field to Request Parameters.Set as Resp Param
Select the table fields to include in the API response.
Set all fields from the
ads_user_info_1dtable as Response Parameters.Sorting Fields
Optional. To sort results, first select the desired fields in the parameter list.
Do not sort.
-
-
Configure the service resource group
After you configure the API in wizard mode, click Resource Group for DataService Studio in the right-side navigation pane to configure the resource group. For more information, see Configure an API service resource group.
Section
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 you do not have a resource group, we recommend that you purchase a general-purpose serverless resource group. For more information, see Use a serverless resource group.
If a newly purchased serverless resource group is grayed out and cannot be selected, you must first allocate a quota for the Data Services service to this resource group. For more information, see Allocate CU quotas to tasks.
Environment Configuration
Timeout
Set the timeout to 30,000 ms.
Maximum Number of Data Records for a Single Request
Set the limit to 2,000.
-
Step 3: Test and publish the API
-
Test the API to verify it returns the correct parameters. For more information, see Test an API.
-
After you finish the configuration, click the
Save icon, and then click the
Test icon to open the API test page. -
In the API Test dialog box, enter values for the request parameters.
-
Click Start Test to run the test.
-
-
Publishing the API deploys it to API Gateway and generates a public endpoint. For more information, see API testing, publishing, and version management.
-
After the API passes the test, return to the API editing page and click the
Submit icon. This creates a new API version. Click Version on the right panel to view its details.
-
Click Publish to publish the API service.
-
After the API is published, you can manage the API by clicking Service Management in the Version panel, or by navigating to . For more information, see Manage and maintain APIs.
-
Next steps
After you publish the API, you can authorize applications to call the API. For more information, see Authorize an API and Call an API.