CLI reference

Updated at: 2025-01-10 07:43

Alibaba Cloud Command Line Interface (CLI) is an open source tool that is built based on Alibaba Cloud SDK for Go. You can run aliyun commands in the CLI to interact with API Gateway and manage your API Gateway resources.

Prerequisites

  1. Alibaba Cloud CLI is installed. For more information, see the following topics:

  2. Alibaba Cloud CLI is configured. For more information, see Configure profiles.

Permissions

If you use a Resource Access Management (RAM) user or RAM role to interact with API Gateway based on the CLI, make sure that the RAM user or RAM role has the permissions to access related resources. For more information, see Identity-based permission policies.

Generate a CLI command

  1. Go to the Debugging page.

  2. In the left-side search box, search for the API operation that you want to call. On the Parameters tab in the middle of the page, specify the parameters by referring to the API document that is displayed on the Document tab on the right. Then, click the CLI Example tab on the right of the page to generate a sample command that carries parameter configurations.

    image

    • Click the image icon to run and debug the command in Cloud Shell. For more information, see What is Cloud Shell?

    • Click the image icon to copy the CLI command to the clipboard and paste it into your local shell.

      • Pay attention to the parameter formats when you copy and paste the CLI command to the local shell. For information about the parameter formats required by Alibaba Cloud CLI, see Parameter formats.

      • By default, OpenAPI Explorer adds the --region option to the generated CLI command. When you copy the command to your local shell, Alibaba Cloud CLI ignores the region information in the default credential configurations and environment variable settings, and preferentially uses the specified region to run the command. You can delete or retain this option based on your business requirements.

Use the CLI to invoke API Gateway

For more information, see Command syntax. Before you invoke API Gateway, make sure that you understand the request parameters and response parameters of the API operations provided for API Gateway. For more information, see List of API operations by function.

Note

The parameters of different data types in the API operations must comply with the parameter format requirements of Alibaba Cloud CLI. For more information, see Parameter formats.

The following examples show how to use Alibaba Cloud CLI to call API Gateway API operations:

  • Query all instances in the China (Hangzhou) region:

    aliyun cloudapi DescribeInstances --region cn-hangzhou
  • Query the details of an API group:

    aliyun cloudapi DescribeApiGroup --region cn-hangzhou --GroupId 2d6e4d64c*******

Usage notes

If you want to perform a complex task by calling API operations in Alibaba Cloud CLI, we recommend that you compile the commands into a shell script and then run the shell script to improve efficiency.

  • On this page (1, T)
  • Prerequisites
  • Permissions
  • Generate a CLI command
  • Use the CLI to invoke API Gateway
  • Usage notes
Feedback