Manage APIs

更新时间:
复制 MD 格式

This topic describes how to view, delete, move, and clone APIs, perform batch operations on them, and find them by using code search.

View an API

  1. Log on to the DataWorks console. In the target region, click Data Analysis and Service > DataService Studio in the left-side navigation pane. Select a workspace from the drop-down list and click Go to DataService Studio.

  2. On the Service Development page, expand the Workflow > API node.

  3. Right-click the target API and select Details.

    Note

    The Details option is available only for published APIs. If an API is not published, you can open its edit page and click Property in the right-side pane to view its basic information.

Clone an API

You can clone an API to a specified path in the directory tree:

  1. On the Service Development page, expand the Workflow > API node.

  2. Right-click the target API and select Cloning.

  3. In the Clone API dialog box, configure the following parameters.

    Parameter

    Description

    API Name

    The name must be 4 to 50 characters in length and can contain Chinese characters, letters, digits, and underscores (_). The name must start with a Chinese character or a letter.

    APIPath

    The path where the API is stored, for example, /user.

    The API Path can contain letters, digits, underscores (_), and hyphens (-). It must start with a forward slash (/) and cannot exceed 200 characters in length.

    Description

    The description of the cloned API.

    Location

    The directory in which to store the API.

  4. Click Confirm.

Delete an API

In DataService Studio, you can delete only unpublished APIs. To delete a published API, you must first unpublish it:

  1. (Optional) Unpublish the API.

    If the API is not published, skip this step.

    1. On the Service Development page, click Service Management at the top to go to the Manage APIs page.

      By default, the page displays a list of Published APIs. The Actions column for each API provides buttons such as Unpublish, Authorization, Test, and More.

    2. On the Published APIs tab, find the target API and click Unpublish in the Actions column.

    3. After you unpublish the API, click Service Development at the top of the page to return to the Service Development page.

  2. On the Service Development page, expand the Workflow > API node.

  3. Right-click the API that you want to delete and select Delete.

    Important

    This operation is irreversible. Proceed with caution.

Move an API

In DataService Studio, you can move only unpublished APIs. To move a published API, you must first unpublish it:

  1. (Optional) Unpublish the API.

    If the API is not published, skip this step.

    1. On the Service Development page, click Service Management at the top to go to the Manage APIs page.

      By default, the page displays a list of Published APIs. The Actions column for each API provides buttons such as Unpublish, Authorization, Test, and More.

    2. On the Published APIs tab, find the target API and click Unpublish in the Actions column.

    3. After you unpublish the API, click Service Development at the top of the page to return to the Service Development page.

  2. On the Service Development page, expand the Workflow > API node.

  3. Right-click the API you want to move and select Move.

  4. In the Move Node dialog box, select the Location and click Confirm.

  5. Important

    Moving an API may change its group, which can affect the endpoint URL after publication. Proceed with caution when moving published APIs.

Batch operations

DataWorks lets you perform batch operations on APIs, such as modifying their DataService Studio resource group, submitting them, and publishing them. This allows you to efficiently switch resource groups and bring the APIs online.

  1. On the Service Development page, click the image.png icon at the top of the directory tree on the left to go to the batch operation page.

  2. At the top of the batch operation page, filter the APIs by criteria such as Workflow and Owner.

  3. In the filtered list, select the checkboxes of the APIs on which you want to perform batch operations.

  4. After selecting the APIs, choose a batch operation from the bottom of the page.

    The following table describes the relationship between batch operations and API states.

    Batch operation

    Unpublished and unsubmitted

    Unpublished and submitted

    Published and unsubmitted

    Published and submitted

    Modify Service Resource Group

    image.png

    image.png

    image.png

    image.png

    Submit

    image.png

    You cannot submit an API that has already been submitted. To resubmit the API, go to its edit page, open the Version Management tab in the right-side pane, and discard the previously submitted version.

    image.png

    You cannot submit an API that has already been submitted. To resubmit the API, go to its edit page, open the Version Management tab in the right-side pane, and discard the previously submitted version.

    Publish

    An API must be submitted before it can be published.

    image.png

    An API must be submitted before it can be published.

    image.png

    Note

    After you change the resource group for a published API, you must test, submit, and publish the API again for the changes to take effect.

API code search

You can search the code of APIs that are created in script mode within the current workspace.

  1. In the left-side navigation pane, click the image.png icon to go to the code search page.

    The left-side pane of the Service Development page contains several function icons, including Code, Table, and Search. The main pane for code search contains the API and Data Push tabs. The search bar allows you to search by ID, name, or API Path. Below the search bar is the collapsible business process section.

  2. Click the image.png icon to the right of the search box to expand the filter options.

    You can enter keywords such as an API name, API Path, API description, table name, or field name in the search box to find APIs. You can also filter the search results by criteria such as owner, business process, and modification time.

  3. View the search results.

    The results that match your search criteria are displayed below the search bar and include the following information:

    Note

    Search results include only published APIs.

    • API name: Click an API name to open its configuration pane on the right.

    • Code content: Shows the matched keyword, its line number, and a brief context. You can copy the matched code.

    • Basic information: Shows the API ID, owner, business process, and last modification time.