All Products
Search
Document Center

Dataphin:Call API

Last Updated:Mar 05, 2025

Calling an API involves an application invoking an API in the production environment. Establishing an API ecosystem for enterprises requires calling APIs for custom development or opening APIs to partners, which facilitates the realization of data assetization and value. This topic introduces how to call an API.

Prerequisites

API documentation entry instructions

  • Accessing API Documentation from the Marketplace: Click Service > Marketplace on the top menu bar. Then, in the left-side navigation pane, click API Service. Next, under the API Documentation section, click the Documentation link for the desired API to navigate to the API Documentation page. This approach provides access to API documentation in the production environment and allows for viewing and downloading the documentation without regard to permissions.

  • Accessing API Documentation through Invocation: Only APIs that are authorized for applications and users with the appropriate permissions can be accessed. To view the API documentation, click Service > Invocation on the top menu bar. Then, in the left-side navigation pane, select a service project and navigate to Service Invocation > Authorized API Service. Click View in the operation column for the desired API to open the API Documentation page. This approach provides access to API documentation within the development environment and supports environment switching and API documentation downloads.

Top operations on the API documentation and debugging page

  • Switch API: In the upper left corner of the page, you can switch to view APIs, conduct a fuzzy search by name or ID, and find APIs published within service projects you are a member of. The system will suggest the nine most recent APIs for you.

  • Switch API Running Environment:

    • API Documentation: Access to API documentation is available exclusively through the Invocation > Authorized API Service page for authorized environments, such as the development or production environment. In the development environment, the public request parameter list includes support for the apiVersion parameter.

    • Debug API: Enables API debugging in authorized environments, such as development or production. It utilizes the development data source in the development environment and the production data source in the production environment for debugging purposes.

      Note
      • When the running environment is the development environment, the sub-APIs of the composite API call use the development environment data source for debugging based on the API configuration submitted in Dev-Prod mode; the production environment data source is used for debugging based on the API configuration submitted in Basic mode.

      • When the running environment is the production environment, the sub-APIs of the composite API call use the production environment data source for debugging based on the API configuration submitted in Dev-Prod mode or Basic mode.

  • Switch API Version: In the development environment, you can select a different API version from the upper right corner of the page while debugging. Only versions that have been submitted, including those that are published, are available for selection.

Step 1: Query and request API

Note

You need to request the application permissions to which the API belongs to use the API.

  1. On the Dataphin home page, select Service > Marketplace from the top menu bar.

  2. Click API Service in the left-side navigation pane, then click the Documentation tab for the desired API under API Documentation to access the API Documentation page. This method provides access to the API documentation within the production environment. The path to the documentation may vary depending on whether the API has been published. For more information, see API documentation entry instructions.

  3. On the API Documentation page, review the Basic Information, Sort Settings (supported only by the service unit API - codeless UI), Business Request Parameter List, Public Request Parameter List, Return Parameter List, and JSON Return Example to ensure they align with your business scenario.

  4. After ensuring the current API suits your business scenario, click Request Now in the Request Status column on the API service page.

  5. On the API Permission Request page, you can request the necessary API permissions. For detailed instructions, see Request API permissions.

Step 2: Debug API

After completing the API permission request, you can debug the API to check if it can be used normally.

  1. Click Invocation on the top menu bar and select a service project.

  2. In the left-side navigation pane, select Service Invocation > Authorized API Service. On the Authorized API Service page, click Debug in the operation column of the target API to access the API Debugging page.

  3. On the API Debugging page, set up the debugging input values and verify that the parameter configuration and API test align with your expectations. For more information, see Step 1: Test API.

    At the top of the API debugging page, you can view the domain name used exclusively for internal testing. To see the actual domain name for invocation, refer to View domain name.

    On the API Debugging page, within the Optional Return Parameter List section, you can swiftly switch between authorized applications using the dropdown in the upper right corner.

Step 3: Download documentation

You can download the API documentation to share with other developers, enhancing flexibility. It supports downloading documents in Word format for easy modification; you can also download it as an OpenAPI specification YAML document for plug-in registration in the BaLian large model.

Download OpenAPI YAML file

  1. On the Dataphin home page, click Service > Marketplace from the top menu bar.

  2. Click API Service in the left-side navigation pane, select the target API, and click Documentation under the API Documentation column.

  3. On the API Documentation page, you can click Download OpenAPI YAML File in the upper right corner.

  4. In the Download Openapi YAML File dialog box, configure the parameters.

    Parameter

    Description

    Format

    Supports downloading files in two formats: Balian Large Model Platform and Openapi Specification.

    operationID

    Interface operation ID, used as a unique identifier for interface operations. Only supports input in English and underscores (_), not exceeding 200 characters.

    summary

    Interface description. Supports input not exceeding 200 characters.

    Code Preview

    After setting, you can preview the code (JSON format) in real-time. For parameter explanations 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 point of the paged query
                      format: int32
                    pageSize:
                      type: integer
                      description: The number of records returned by the 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 values (note uppercase), only ASC or DESC
                          order:
                            type: string
                            description: Sort type, enumeration values (note uppercase), only ASC or DESC
                            example: ASC or DESC
            required: true
    
  5. After configuring, click Download to retrieve the file onto your local system.

Download API documentation

  1. On the Dataphin home page, click Service > Marketplace from the top menu bar.

  2. Click API Service in the left-side navigation pane, then click the Documentation column for the desired API under API Documentation .

  3. On the API Documentation page, you can click Download API Documentation in the upper right corner to download a single API document. Alternatively, select multiple APIs on the API Service page and click Download API Documentation at the bottom for a batch download of API documents.

    Note
    • The API documentation you download will provide specific examples for invoking the API, simplifying the usage process; you can also tailor these examples to your needs using the .

    • Supports downloading API documentation to the local system in Word format.

    • API documentation includes the document directory, document version, API invocation examples, interface list (by interface dimension, each interface content includes basic information, sort settings (only supported by service unit API - codeless UI), business request parameter list, public request parameter list, return parameter list, JSON return example, and specific invocation examples of the API).

API invocation template

Note

Only super administrators support managing SDK and invocation examples, and editing invocation instructions.

  1. On the DataService Studio page, click Invocation in the top menu bar, then click Invocation Instructions in the left-side navigation pane to access the invocation instructions page.

  2. On the invocation instructions page, click the API Invocation Instructions tab to access the API invocation instructions.

  3. On the API Invocation Instructions page, you can view the API invocation example template, and then carry out the necessary operations.

    • Download Default Invocation Example: To download the API invocation example, click Download Default Invocation Example.

    • Download Python Invocation Example: To call the API using Python, click Download Python Invocation Example to retrieve the Python example file package.

    • Download Java SDK: To call the API using the Java SDK, click Download Java SDK to retrieve the code package.

    • Manage SDK and Invocation Examples: To access the SDK management and invocation examples page, click the Manage SDK and Invocation Examples button. Here, you can manage API invocation examples in a unified manner, including adding new examples or sorting existing ones.

      • Add: To add an invocation example, click the Add button at the bottom.

        • Name: Enter a unique name for the invocation example to be displayed on the API invocation instructions page. It is recommended to limit the name to no more than 10 characters, although the maximum allowed is 50 characters.

        • Description: Provide a concise description of the invocation example, limited to 100 characters, to assist relevant business personnel in understanding its purpose.

        • Upload File: To upload a file to Dataphin, click the Upload button, select the desired file from your local system, and proceed with the upload. The supported file formats include zip, rar, doc, docx, PDF, and jpg, and the file size must not exceed 200M.

          Supports downloading files to the local system.

        • Display: Determines the visibility of the invocation example on the API invocation instructions page. It is enabled by default after saving, but you can choose to disable it.

        • Save: Allows you to save modified or newly added invocation examples.

        • Edit/ Delete: Allows you to modify or delete custom invocation example configurations.

      • Sort: Click Sort, drag the invocation examples to reorder them, and click the Complete button in the upper right corner to finalize the sorting. The order you set will determine the default display sequence on the API Invocation Instructions page.

        Note
        • Supports creating no more than 10 API invocation examples (including system default invocation examples).

        • System default invocation examples do not support editing or deletion, but you can choose whether to display the invocation example.

    • Edit Invocation Instructions: Allows for the customization of API invocation instructions to suit specific business scenarios.

  4. Invoke the API following the provided invocation example instructions.

API return count

After calling the API, you can query data. The query count supported for different service types and data sources is shown in the table below.

Data source type

Maximum return count per query

Total query count limit

Support for paged query

Single physical table service unit

MySQL

10000

No upper limit

Supported

AnalyticDB for MySQL2.0

Supported

ElasticSearch

Supported

Microsoft SQL Server

Not supported

PostgreSQL

Supported

AnalyticDB for MySQL3.0

Supported

AnalyticDB for PostgreSQL

Supported

Hologres

Supported

HBase (0.9.4/1.1.x/1.2.1/2.x)

10000

10000

Supported

Oracle

Supported

MongoDB

Supported

Multiple physical table service unit

MySQL

10000

No upper limit

Supported

AnalyticDB for MySQL2.0

Supported

ElasticSearch

Supported

Microsoft SQL Server

Not supported

PostgreSQL

Supported

AnalyticDB for MySQL3.0

Supported

AnalyticDB for PostgreSQL

Supported

Hologres

Supported

HBase (0.9.4/1.1.x/1.2.1/2.x)

10000

10000

Supported

Oracle

Supported

MongoDB

Supported

Direct connection data source API

Impala

10000

No upper limit

Supported

Oracle

Supported

MySQL

Supported

PostgreSQL

Supported

Microsoft SQL Server

Supported

Hologres

Supported

Lindorm

Supported

ClickHouse

Supported

StarRocks

Supported

TDengine

Not supported

SAP HANA

Not supported

SelectDB

Supported

HBase (0.9.4/1.1.x/1.2.1/2.x)

1

No upper limit

Not supported

ElasticSearch

10000

10000

Supported

Logical table API

N/A

10000

10000

Supported

Dataphin data source

Dataphin data source

10000

No upper limit

Supported

When calling the API through the SDK, if you need to query data from the 9000th to the 10000th record, configure the public request parameter PageStart to 9000 and PageSize to 1000.