Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The Alibaba Cloud V1.0 SDK will soon enter the Basic Security Maintenance phase and is no longer recommended for use.

License

NotificationsYou must be signed in to change notification settings

aliyun/aliyun-openapi-python-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codacy BadgeBuild StatusBuild statuscodecov

中文文档

The Alibaba Cloud Python Software Development Kit (SDK) allows you to access Alibaba Cloud services such as Elastic Compute Service (ECS), Object Storage Service (OSS), and Resource Access Management (RAM). You can access Alibaba Cloud services without the need to handle API related tasks, such as signing and constructing your requests.

This document introduces how to obtain and call Alibaba Cloud Python SDK.

Online Demo

API Explorer provides the ability to call the cloud product OpenAPI online, and dynamically generate SDK Example code and quick retrieval interface, which can significantly reduce the difficulty of using the cloud API.It is highly recommended.

Prerequisites

  • To use Alibaba Cloud Python SDK, you must have an Alibaba Cloud account as well as an AccessKey.

    The AccessKey is required when initializingAcsClient. You can create an AccessKey in the Alibaba Cloud console. For more information, seeCreate an AccessKey.

    Note: To increase the security of your account, we recommend that you use the AccessKey of the RAM user to access Alibaba Cloud services.

  • To use Alibaba Cloud Python SDK to access the APIs of a product, you must first activate the product on theAlibaba Cloud console if required.

  • Alibaba Cloud Python SDK requires 2.6.x, 2.7.x, and Python 3.x.

Install Python SDK

Alibaba Cloud Python SDK supports Python 2.6.x, 2.7.x, and Python 3.x. Runpython --version to check your version of Python.

You can install the Alibaba Cloud Python SDK using the following two methods. Regardless of which method and cloud service are used, the core libraryaliyun-python-sdk-core must be installed.

  • Install with pip

    Python SDK uses a common package management tool namedpip. If pip is not installed, see thepip user guide to install pip.

    Run the following command to install the individual libraries of Alibaba Cloud services:

    # Install the core library pip install aliyun-python-sdk-core# Install the ECS management library pip install aliyun-python-sdk-ecs# Install the RDS management library pip install aliyun-python-sdk-rds

Use Python SDK

  1. Import the required modules as follows:

    fromaliyunsdkcore.clientimportAcsClientfromaliyunsdkcore.acs_exception.exceptionsimportClientExceptionfromaliyunsdkcore.acs_exception.exceptionsimportServerExceptionfromaliyunsdkecs.request.v20140526importDescribeInstancesRequestfromaliyunsdkecs.request.v20140526importStopInstanceRequest
  2. Initialize theAcsClient instance:

    client=AcsClient("<access-key-id>","<access-key-secret>","<region-id>");

    where:

    • access-key-id is the Accesskey ID for your account.
    • access-key-secret is the AccessKey secret for your account.
    • region-id is the ID of the region where the service is called. For a list of region IDs, seeRegions and zones.

    Note: The sequence of these parameters cannot be changed.

  3. Initialize a request and print response.

    # Initialize a request and set parametersrequest=DescribeInstancesRequest.DescribeInstancesRequest()request.set_PageSize(10)# Print responseresponse=client.do_action_with_exception(request)printresponse

Code example

The following example shows how to query a list of ECS instances in a specific region usingDescribeInstances. Substitute the values foryour-access-key-id,your-access-key-secret, andyour-region-id.

# -*- coding: utf8 -*-fromaliyunsdkcore.clientimportAcsClientfromaliyunsdkcore.acs_exception.exceptionsimportClientExceptionfromaliyunsdkcore.acs_exception.exceptionsimportServerExceptionfromaliyunsdkecs.request.v20140526importDescribeInstancesRequestfromaliyunsdkecs.request.v20140526importStopInstanceRequest# Initialize AcsClient instanceclient=AcsClient("<your-access-key-id>","<your-access-key-secret>","<your-region-id>");# Initialize a request and set parametersrequest=DescribeInstancesRequest.DescribeInstancesRequest()request.set_PageSize(10)# Print responseresponse=client.do_action_with_exception(request)printresponse

About

The Alibaba Cloud V1.0 SDK will soon enter the Basic Security Maintenance phase and is no longer recommended for use.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors26

Languages


[8]ページ先頭

©2009-2025 Movatter.jp