Calling an API means that an application calls the API in the current environment based on the runtime environment. In Basic mode, even if the runtime environment is the development environment, the data read is still from the production environment. In scenarios where you need to build an API ecosystem for your enterprise, you can call APIs for custom development or share APIs with partners to help your enterprise monetize and maximize the value of data. This topic describes how to call an API.
Prerequisites
The API is published to the Data Service marketplace. For more information, see Test and publish an API.
You need to create an application first. For more information, see Create an application.
API documentation entry description
Access API documentation from the marketplace: In the top menu bar, click Service > API Marketplace. In the navigation pane on the left, click the API tab. In the Documentation column for the target API, click API Documentation to open the API Documentation page for the production environment. You can view and download the API documentation regardless of your permissions.
Access API documentation from Application Management: You can use this method only if the API is authorized for an application and you have the necessary permissions. In the top menu bar, click Service > Application Management. In the navigation pane on the left, choose Service Management > Authorized API Services. In the Actions column for the target API, click View to open the API Documentation page. This opens the API documentation for the development environment. You can switch environments and download the API documentation.
Operations at the top of the API documentation and debugging page
Switch API: You can switch APIs to view in the upper-left corner of the page. You can search for APIs by name or ID using fuzzy search. The system supports searching for published APIs in the service projects that the current user has joined. The system will recommend the 9 most recent APIs for you.
Switch API Runtime Environment:
API Documentation: From the Application Management > Authorized API Services page, you can select an environment (development environment or production environment) to view its API documentation, provided you have the required permissions. When the runtime environment is the development environment, the list of common request parameters includes the apiVersion parameter.
Debug API: You can select environments (development environment, production environment) for which you have permissions to debug the API. When the runtime environment is the development environment, the development data source is used for debugging. When the runtime environment is the production environment, the production data source is used for debugging.
NoteWhen the runtime environment is the development environment, for combination APIs, sub-APIs configured in Dev-Prod mode use the development environment data source for debugging, while sub-APIs configured in Basic mode use the production environment data source for debugging.
When the runtime environment is the production environment, for combination APIs, sub-APIs configured in either Dev-Prod mode or Basic mode use the production environment data source for debugging.
Switch API Version: When the runtime environment is the development environment, you can switch API versions in the upper-right corner of the page when debugging an API. You can only select submitted versions (including published versions).
Step 1: Query and request an API
You need to request permissions for the application that owns the API before you can use the API.
In the top menu bar of the Dataphin homepage, choose Service > API Marketplace.
Click the API tab, and then click Documentation column of the target API under API Documentation to go to the API Documentation page. This method accesses the API documentation in the production environment. The path may vary depending on whether the API is published. For more information, see API documentation entry description.
On the API Documentation page, check the API's Basic Information, Sort Settings (only supported for service unit APIs in codeless UI mode), Business Request Parameter List, Common Request Parameter List, Row-Level Permission List, Response Parameter List, and JSON Response Example to determine whether they meet your business requirements.
NoteWhen the API type is Direct Data Source API, Service Unit API, or Combination API and row-level permission is enabled, you can view the row-level permission list information.
When the call mode is asynchronous invocation, API data caching is not supported. Data can be incrementally obtained through cursors. Therefore, asynchronous invocation does not require cache and result paging configurations, and the common request parameters do not display PageSize and PageStart information.
After confirming that the current API meets your business requirements, click Request Status column under Request Now on the API Service page. You will be redirected to the Management Hub > Permission Management > My Permissions > Data Service Permissions page to request permissions for the API. For more information, see Request API permissions.
Step 2: Debug the API
After you complete the API permission request, you can debug the API to verify that it works properly.
When you debug an API, the input parameter cannot exceed 1,000 characters. If you call the API directly, no character limit is applied.
In the top menu bar, click Application Management.
In the navigation pane on the left, choose Service Management > Authorized API Services. On the Authorized API Services page, in the Actions column for the target API, click Debug to open the API Debugging page.
On the API Debugging page, configure the debug input values. For more information about debugging parameters and testing whether the API meets your expectations, see Step 1: Test the API.
You can view the domain name at the top of the API debugging page. This domain name is only used for internal testing. For the actual domain name to call, see View domain name.
In the API Debugging page's Optional Response Parameter List section, you can quickly switch between authorized applications in the upper-right corner.
Step 3: Download documentation
You can download API documentation to share with other developers, increasing flexibility of use. You can download the documentation in Word format for easy editing, or as an OpenAPI specification YAML document for Alibaba Cloud Model Studio plugin registration.
Download OpenAPI YAML file
On the Dataphin homepage, click Service > API Marketplace in the top menu bar.
In the list on the left, click the API tab. In the target API's Documentation column, click API Documentation.
On the API Documentation page, click Download OpenAPI YAML File in the upper-right corner.
In the Download OpenAPI YAML File dialog box, configure the parameters.
Parameter
Description
Format
You can download files in two formats: Alibaba Cloud Model Studio and OpenAPI Specification.
operationID
The operation ID for the interface, used as a unique identifier for the interface operation. Only English letters and underscores (_) are supported, with a maximum of 200 characters.
summary
The operation description. Maximum 200 characters.
Code Preview
After completing the settings, you can preview the code (in JSON format) in real-time. For explanations of the parameters in the code, see OpenAPI Specification.
openapi: 3.0.1 info: title: sq_test_mysql description: "" version: V1.4 servers: - url: http://528fdcdcc62d4f4eb8f10ad99cdda9f3-cn-shanghai.alicloudapi.com paths: /list/10172: post: summary: "" operationId: "" parameters: - name: appKey in: query description: The application key bound to access the API required: true schema: type: string example: "2000001" - name: env in: query description: The environment where the API is located required: true schema: type: string example: "prod:Production environment, pre:Staging environment" requestBody: content: application/json: schema: required: - returnFields type: object properties: useModelCache: type: boolean description: "Whether to enable SQL translation cache, which helps improve query performance" default: false pageStart: type: integer description: The starting position for paged query format: int32 pageSize: type: integer description: The number of records returned in a paged query format: int32 returnFields: type: array items: type: string example: "[id, name, sexo]" conditions: required: - sex type: object properties: namee: type: string example: null sex: type: string example: null idd: type: string example: null description: Input parameter conditions useResultCache: type: boolean description: "Whether to enable API query result cache, which helps improve query performance" default: false orderBys: type: array description: Sort fields items: type: object properties: field: type: string description: Sort type, enumeration value (note uppercase), only ASC or DESC order: type: string description: Sort type, enumeration value (note uppercase), only ASC or DESC example: ASC or DESC required: trueAfter completing the configuration, click Download to download the file to your local computer.
Download API documentation
On the Dataphin homepage, click Service > API Marketplace in the top menu bar.
Click the API tab in the list on the left. In the Documentation column for the target API, click API Documentation.
On the API Documentation page, click Download API Documentation in the upper-right corner to download a single API document. You can also select multiple APIs on the API Service page and click Download API Documentation at the bottom to batch download API documentation.
NoteThe downloaded API documentation includes specific call examples generated based on the API for your convenience. You can also configure call examples according to API call templates.
You can download the API documentation to your local computer in Word format.
The API documentation includes a table of contents, document version, API call examples, and interface list (organized by interface, with each interface including basic information, sort settings (only for service unit APIs in codeless UI mode), business request parameter list, common request parameter list, row-level permission list (only supported when Direct Data Source API, Service Unit API, or Combination API has row-level permission enabled), response parameter list, JSON response example, and specific call examples for the API).
When the API gateway configured in the network is Alibaba Cloud API Gateway, and the public second-level domain/internal VPC domain is enabled and visible to all users, you can view the correct Host information in the downloaded API documentation . If it is an internal gateway, you can view the correct Host information only when Display Domain Name is set to Yes.
API call templates
Only super administrators can manage SDKs and call examples, and edit call instructions.
On the DataService Studio page, click Application Management in the menu bar. In the navigation pane on the left, click Call Instructions.
On the Call Instructions page, click the API Call Instructions tab to go to the API Call Instructions page.
On the API Call Instructions page, view the templates for API call examples and perform the following operations.
Download Default Call Examples: You can click Download Default Call Examples to download API call examples, including synchronous and asynchronous calls.
Download Python Call Examples: To call APIs using Python, click Download Python Call Examples to download a compressed file of Python examples.
Download Java SDK: To call APIs using the Java SDK, click Download Java SDK to download the Java SDK code package.
Manage SDKs And Call Examples: Click the Manage SDKs And Call Examples button to go to the Manage SDKs and Call Examples page, where you can centrally manage API call examples, add new call examples, or sort call examples.
Add: Click the Add button at the bottom to add a call example.
Name: Enter a name for the call example, which will be displayed on the API Call Instructions page. The name must be unique. We recommend that you enter no more than 10 characters, with a maximum of 50 characters.
Description: Enter a brief description of the call example to help relevant business personnel understand its purpose. Maximum 100 characters.
Upload File: Click the Upload button to select a file from your local computer and upload it to Dataphin. Supported file formats include zip, rar, doc, docx, PDF, and jpg, with a maximum file size of 200 MB.
You can download the file to your local computer.
Display: Determines whether the call example is visible on the API Call Instructions page. After saving, this option is enabled by default. You can disable the call example.
Save: Save the modified or newly added call example.
Edit/Delete: Modify or delete the configuration information of custom call examples.
Sort: Click Sort, drag the call examples to sort them, and click the Complete button in the upper-right corner to complete the sorting. The sort order here will affect the default display order on the API Call Instructions page.
NoteYou can create up to 10 API call examples (including the call examples provided by the system by default).
The call examples provided by the system by default cannot be edited or deleted, but you can choose whether to display them.
Edit Call Instructions: Modify the API call instructions based on your business scenarios.
Call the API according to the call example instructions.
API return record limits
After you call an API, you can query data. For synchronous calls, a maximum of 10,000 records can be returned per query. For both synchronous and asynchronous calls, there is no limit on the total number of records that you can query.
Data Source Type | Support for Paged Query | |
Single-physical-table service unit | MySQL/Amazon RDS for MySQL | support |
AnalyticDB for MySQL2.0 | support | |
ElasticSearch | support | |
Microsoft SQL Server/Amazon RDS for SQL Server | not support | |
PostgreSQL/Amazon RDS for PostgreSQL | support | |
AnalyticDB for MySQL3.0 | support | |
AnalyticDB for PostgreSQL | support | |
Hologres | support | |
Hbase (0.9.4/1.1.x/1.2.1/2.x) | support | |
Oracle/Amazon RDS for Oracle | support | |
MongoDB | support | |
DM (Dameng) | Not supported | |
Amazon Redshift | Not supported | |
OceanBase | Not supported | |
Multi-physical-table service unit | MySQL/Amazon RDS for MySQL | support |
AnalyticDB for MySQL2.0 | support | |
ElasticSearch | support | |
Microsoft SQL Server/Amazon RDS for SQL Server | not support | |
PostgreSQL/Amazon RDS for PostgreSQL | support | |
AnalyticDB for MySQL3.0 | support | |
AnalyticDB for PostgreSQL | support | |
Hologres | support | |
Hbase (0.9.4/1.1.x/1.2.1/2.x) | support | |
Oracle/Amazon RDS for Oracle | support | |
MongoDB | support | |
DM (Dameng) | Supported | |
Amazon Redshift | Not supported | |
OceanBase | Not supported | |
Direct-connect data source API | Impala | support |
Oracle/Amazon RDS for Oracle | support | |
MySQL/Amazon RDS for MySQL | support | |
PostgreSQL/Amazon RDS for PostgreSQL | support | |
Microsoft SQL Server/Amazon RDS for SQL Server | support | |
Hologres | support | |
Lindorm | support | |
ClickHouse | support | |
StarRocks | support | |
TDengine | not support | |
SAP HANA | not support | |
SelectDB | support | |
Hbase (0.9.4/1.1.x/1.2.1/2.x) | not support | |
ElasticSearch | support | |
DM (Dameng) | Supported | |
Amazon Redshift | Supported | |
GaussDB (DWS) | Supported | |
OceanBase | Supported | |
TDH Inceptor | Supported | |
MaxCompute | Supported | |
Databricks | Supported | |
Logical table API | None | support |