Create API (dataset) in wizard mode

Updated at:

You can quickly create an API from a dataset by configuring parameters in the GUI, enabling features such as vector queries and the generation of file download links. This topic describes how to generate an API using wizard mode.

Prerequisites

  • To use the dataset API, you must have purchased the unstructured data and data service features.

  • You must create and submit a dataset in Development > Data Development > Datasets. For details, see Create and manage datasets.

Limits

  • When using pagination in an API query, specify a sort order to ensure stable results and prevent duplicate or missing entries. The pagination parameters, PageStart and PageSize, appear on the API debugging page only when pagination is enabled.

  • You can use PageStart and PageSize in an API call to configure pagination, but these parameters only take effect when pagination is enabled.

Permissions

In the data service, project administrators and developers can generate APIs.

Notes

An API's request and response parameters must be from the same dataset, or subsequent calls will fail.

Step 1: Select API creation mode

  1. On the Dataphin homepage, choose service > API development from the top menu bar.

  2. Select a project in the upper-left corner. In the left navigation pane, click API service. On the API page, click + new API.

  3. In the new API dialog box, select dataset API - wizard mode.

Step 2: Configure API parameters

  1. On the Create API page, configure the API's basic information and parameters.

    API basic information

    Parameter

    Description

    API name

    Enter a name for the API. The name must meet the following requirements:

    • Must contain only Chinese characters, letters, digits, and underscores (_).

    • Must be 4 to 100 characters long.

    • Must start with a letter.

    • Must be globally unique.

    Operation type

    The supported operation types are GET and LIST.

    • GET: Requests a specific resource from the server.

    • LIST: Requests a subset of resources from the server.

    Data update frequency

    Specifies how often the API response data is updated. This helps callers understand data freshness. Supported frequencies are Daily, Hourly, Minutely, and Custom. If you select Custom, you can enter up to 128 characters.

    API group

    Select an API group from the current project. To create one, see Create a group.

    Result pagination

    This setting is available when the operation type is LIST. When you enable this feature, you must specify a sort field to ensure a stable order of query results and prevent duplicate or missing results. If this feature is disabled, the pagination parameters (PageStart and PageSize) are hidden on the API debugging or testing page. However, you can display these parameters by deselecting an option on that page.

    Description

    Enter a brief description of the API, up to 128 characters long.

    Protocol

    Specifies the protocol for the data generation API. Only HTTP is supported.

    HTTP: HyperText Transfer Protocol. It is the most widely used network protocol.

    Invocation mode

    Specifies the communication mode between the client and server. Only synchronous invocation is supported.

    synchronous invocation: This mode is suitable for operations that require immediate responses and have short processing times. For long-running queries, this synchronous waiting can result in long response times and increased server load as connections are held open.

    Timeout

    Specifies the maximum time allowed for an API call. The default is 3 seconds. Valid values are positive integers from 3 to 60 seconds.

    If an API call exceeds the configured timeout, the call fails and returns an error. This helps you promptly detect and handle API call exceptions. For more information about viewing exceptions, see Monitor an API operation.

    Maximum returned entries

    This setting is available only when the operation type is LIST. The maximum number of entries returned by an API call is 10,000. You can enter a positive integer from 1 to 10,000.

    Cache settings

    You can enable or disable this feature. If enabled, you must configure the cache duration. The default value is 300 seconds. You can set the duration to a positive integer from 60 to 1,000,000 seconds (approximately 277.78 hours).

    Version

    Specifies a unique version for the API configuration. This versioning allows you to track and compare changes to the API. The version must meet the following requirements:

    • Must not exceed 64 characters.

    • Must contain only uppercase and lowercase letters, digits, underscores (_), periods (.), and hyphens (-).

    Response type

    The default value is JSON.

    Return SQL

    Controls whether the API response includes the actual SQL statement that was executed.

    • Select Yes (enable): The API response returns the SQL statement executed by the database.

    • Select No (disable): The API response shows the original SQL script.

  2. API request and response parameters

    Table and mixed datasets

    To configure API Request Parameters and Response Parameters, first identify the source (Dataset) for the API's input and output parameters. Then, add the input and output parameters to the Request Parameters and Response Parameters sections, respectively. Finally, configure the basic information for the Request Parameters and Response Parameters.

    1. In the parameter configuration section, after you select a dataset, its fields appear in the list below.

      Parameter

      Description

      Mode

      Only Basic mode is supported. In Basic mode, both development and submission operations read from the production database.

      Project

      Select a project in the chosen mode.

      Dataset

      Select a published dataset and its version from the selected project.

      Dataset fields

      Shows the fields from the selected dataset. URL fields are marked with the image icon, and vector fields are marked with the image icon.

      Actions

      Click to open the data preview panel. By default, the system returns the first 100 rows from the current dataset. You can set the number of returned rows to 10, 50, 100, 500, or 1000.

    2. Hover over a dataset field and click Request Parameter or Response Parameter to add it to the Request Parameters or Response Parameters list on the right.

      • For a vector field, you can configure a vector query to enable semantic search. This feature reuses the field's configured Embedding model and vector index. The system converts the user's input query into a vector, searches independently across all fields with vector query enabled, and then merges the results using weighted fusion to produce the final output. Click Show Vector Configuration or Vector Query under the mapped field in the request parameters list to open the Vector Field Weight Configuration list and set the weights.

        • Vector query: When enabled, uses this field for vector queries. The system automatically adds the query and top_k request parameters, and the _score response parameter.

          • query: The input text for the search.

          • top_k: The number of most similar results to return.

          • _score: Quantifies the relevance between the query text and the returned results.

          • Weight: A factor that determines the contribution of each vector field to the final score. The sum of all field weights should be 1.0.

        • Distance metric: The mathematical algorithm used in vector retrieval to calculate the similarity between two vectors. In a vector space, a smaller distance (or a smaller angle) indicates greater semantic similarity. You can select cosine similarity, Euclidean distance, or inner product.

          • Cosine similarity: Suitable for semantic retrieval scenarios where text length is not a significant factor, such as document search, question-answering matching, and semantic deduplication.

          • Euclidean distance: Affected by both vector direction and magnitude (numerical size). If two vectors have the same direction but vastly different magnitudes, this metric considers them dissimilar. This is suitable for scenarios that are sensitive to numerical magnitude.

          • Inner product: Calculates the sum of the products of corresponding dimensions of two vectors. It is computationally fast and suitable for retrieval scenarios that require high performance.

        • Minimum score threshold: Controls the final retrieval results. Results with a score greater than or equal to the threshold are returned; those with a score below the threshold are filtered out.

      • For download link fields from OSS, Amazon S3, or OBS data sources, you can configure domain name replacement and expiration time.

        • Domain name replacement: If enabled, enter the domain name to substitute. If disabled, the default domain of the file storage service is used.

        • Expiration time: The expiration time for the link. The default is 3,600 seconds, and the configurable range is from 60 to 86,400 seconds (24 hours).

        Parameter

        Description

        Request Parameters

        Parameter name

        The public-facing parameter name for API calls. The name must follow these rules:

        • The parameter name must be unique.

        • Can contain letters, digits, and underscores (_).

        • Must start with a letter.

        • Must be 1 to 64 characters long.

        Mapped field

        The internal dataset field mapped to the parameter. Not exposed to users.

        Parameter type

        The parameter's data type, which is inherited from the mapped dataset field.

        Supported types include double, float, string, Date(yyyy-MM-dd HH:mm:ss), Boolean, int, long, short, byte, BigDecimal, and binary.

        The request parameter's type must match the type of the mapped dataset field.

        Operator

        Defines how the request parameter is processed when the API is called. For a list of supported operators and their descriptions, see Supported operators for API development.

        Default value

        Used if the caller provides no value for this parameter. If no default is set, the value is NULL. The maximum length is 1,000 characters.

        Example

        An example value to help developers understand its usage. For instance, if the Parameter Name is ID, the Parameter Type is Int, and the Operator is =, an example value could be 5.

        Description

        A brief description of the request parameter. The maximum length is 1,000 characters.

        Required

        Specifies whether the parameter is mandatory in an API call.

        • No: The API call can succeed if this parameter is omitted.

        • Yes: The API call fails if this parameter is omitted.

        For example, assume the request parameter is id and is required, and the response parameter is name. The following statements will produce different results:

        • select name from tableA where id=5;: Returns the corresponding name field and its data.

        • select name from tableA;: The SQL statement execution fails.

        Actions

        After the query and top_k vector fields are deleted, you can restore them. You cannot modify their names, parameter types, or other settings.

        Response Parameters

        Parameter name

        The public-facing parameter name returned to the user. The name must follow these rules:

        • The parameter name must be unique.

        • Can contain letters, digits, and underscores (_).

        • Must start with a letter.

        • Must be 1 to 64 characters long.

        Note

        When you use a mixed dataset and add a download link field to the response parameters list, the system automatically generates a file_url field. The names of the file_url and {field_name}_download parameters cannot be modified.

        Mapped field

        The internal dataset field mapped to this response parameter. For mixed datasets, download link fields are displayed and marked with the image icon.

        Parameter type

        The data type of the value returned by the API.

        Supported types include double, float, string, Date(yyyy-MM-dd HH:mm:ss), Boolean, int, long, short, byte, BigDecimal, binary, and vector.

        Note
        • The response parameter's type must match the type of the mapped dataset field.

        • When you use a mixed dataset, the parameter types for file_url and {field_name}_download cannot be modified.

        Example

        An example of a returned value that helps developers understand the response format. The maximum length is 1,000 characters.

        Description

        A brief description of the response parameter. The maximum length is 1,000 characters.

        Actions

        After the _score vector field is deleted, you can restore it. You cannot modify its name, parameter type, or other settings.

    3. In the list on the left, select one or more fields. Then click More > Sort Fields to add the selected dataset fields to the Sort Fields list on the right.

      Specifying sort fields is optional. However, if you enable pagination, you must specify sort fields to ensure a stable order for query results and prevent duplicate or missing results in paginated responses. If sort parameters are specified in the request, they override the settings configured here.

      Parameter

      Description

      Sort field

      Select a field from the dataset to sort by.

      Sort order

      Supports Ascending and Descending.

      Actions

      You can drag and drop fields to reorder them by using the image.png icon, or use the icons in the Actions column to change the order. From left to right, the icons are: Move Up, Move Down, and Delete.

      Note
      • The order of the fields in the list determines the sort priority, from highest to lowest.

      • If the API's request method is GET, the API returns only the first result after sorting.

    File datasets

    To configure API request parameters and response parameters, first specify the source dataset, and then configure the request and response parameters.

    1. In the parameter configuration section, select a dataset.

      Parameter

      Description

      Mode

      Only Basic mode is supported. In Basic mode, both development and submission operations read from the production database.

      Project

      Select a project in the chosen mode.

      Dataset

      Select a published dataset and its version from the selected project.

    2. After you select a dataset, the system automatically adds the dataset fields to the Request Parameters and Response Parameters lists on the right.

      When the data source is OSS, Amazon S3, or OBS, you can configure domain name replacement and expiration time for download link fields.

      • Domain name replacement: If enabled, enter the domain name to substitute. If disabled, the default domain of the file storage service is used.

      • Expiration time: The expiration time for the link. The default is 3,600 seconds, and the configurable range is from 60 to 86,400 seconds (24 hours).

      Parameter

      Description

      Request Parameters

      Parameter name

      The system automatically generates the unmodifiable path_prefix and max_rows fields.

      • path_prefix: Specifies the root directory for data retrieval or scanning. Example: docs/.

      • max_rows: Controls the maximum number of rows returned in a single request. The default is 100, and the maximum is 1,000.

      Parameter type

      Displays the field type from the dataset. This setting cannot be modified.

      Operator

      Defines how the request parameter is processed when the API is called. This setting cannot be modified. For a list of supported operators and their descriptions, see Supported operators for API development.

      Default value

      Used if the caller provides no value for this parameter. If no default is set, the value is NULL. The maximum length is 1,000 characters.

      Example

      An example value for the request parameter to help developers understand its usage. For instance, if the Parameter Name is ID, the Parameter Type is Int, and the Operator is =, an example value could be 5.

      Description

      The system automatically populates this with the corresponding field's description, which you can modify. The maximum length is 1,000 characters.

      Required

      Specifies whether the request parameter is mandatory for an API call.

      • No: The API call can succeed if this parameter is omitted.

      • Yes: The API call fails if this parameter is omitted.

      For example, assume the request parameter is id and is required, and the response parameter is name. The following statements will produce different results:

      • select name from tableA where id=5;: Returns the corresponding name field and its data.

      • select name from tableA;: The SQL statement execution fails.

      Actions

      The delete operation is not supported.

      Response Parameters

      Parameter name

      The system automatically generates the following unmodifiable fields: file_url, {field_name}_download, size, file_extension, mime_type, modified_time, file_name, and file_path.

      • file_url: The storage address of the file.

      • {field_name}_download: A temporary download link. The field name is the same as the source field name.

      • size: The file size in bytes.

      • file_extension: The file extension.

      • mime_type: The Multipurpose Internet Mail Extensions (MIME) type.

      • modified_time: The time when the file was last modified.

      • file_name: The name of the file.

      • file_path: The path to the file.

      Mapped field

      The internal parameter used in an API call, which is not exposed to the user. Download link fields are marked with the image icon.

      Parameter type

      The data type of the API response. This setting cannot be modified.

      Example

      An example of a returned value to help developers understand the response format. The maximum length is 1,000 characters.

      Description

      The system automatically populates this with the corresponding field's description, which you can modify. The maximum length is 1,000 characters.

      Actions

      You can restore a field after it has been deleted.

  3. Click Submit to validate that the API's referenced fields exist in the associated dataset; a successful validation generates the API.

Next steps

  • After you generate an API, you must test and publish it to the data service market so that applications can call the API. For more information, see Test and Publish an API.

  • If you need to delete an API, manage its versions, or transfer its owner, see Manage APIs.