All Products
Search
Document Center

:Call API operations by using SDKs

Last Updated:May 22, 2024

OpenAPI Explorer can automatically generate Java, Python, PHP and Node.js SDK examples based on your API request.

This topic describes how to obtain dynamic sample code and call API operations. For information about Alibaba Cloud SDKs, see Alibaba Cloud SDKs.

Procedure

Download the project code

  1. Log on to OpenAPI Explorer.

  2. In the top navigation bar, move the pointer over Cloud Products and find the cloud service that you want to manage.

  3. Click the service name to go to Product Homepage. In the upper-right corner of the page, click Debug. A page with three columns appears.

    image.png

  4. Select the API operation that you want to call in the leftmost column. Configure the required parameters in the middle column. Then, click the SDK Sample Code tab in the rightmost column.

  5. Select V2.0 from the SDK Version drop-down list and select a language based on your business requirements.

  6. Click Download Project to download the sample code.

  7. If you want to generate the sample code of a generic call, turn on Common Request. For more information, see Generic calls and specialized calls.

Create a user identity and logon credentials

You can call API operations by using an Alibaba Cloud account or a Resource Access Management (RAM) role, or as a RAM user. For more information about the differences between the identities, see Identity, credential, and authorization.

Configure environment variables

Configure the ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables. For more information, see Set environment variables in the Linux, macOS, or Windows operating system.

Run the code

  1. Decompress the downloaded package and use IDEA to open the project.

  2. Add the Maven dependency.

  3. Click Run.