- Notifications
You must be signed in to change notification settings - Fork582
The Alibaba Cloud V1.0 SDK will soon enter the Basic Security Maintenance phase and is no longer recommended for use.
License
aliyun/aliyun-openapi-python-sdk
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The Alibaba Cloud V1.0 SDK will soon enter the Basic Security Maintenance phase and is no longer recommended for use. It is suggested to use the V2.0 SDK instead.
Troubleshoot Provide OpenAPI diagnosis service to help developers locate quickly and provide solutions for developers throughRequestID orerror message.
API Developer Portal 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.

- Starting from version 2.16.0, the Alibaba Cloud Python SDK core library
aliyun-python-sdk-coreonly supports Python 3.7 and above.
- Requirements
- Installation
- Client & Credentials
- Timeout
- Proxy Configurations
- Log
- Endpoint
- Https
- Debug
- Exception
To use Alibaba Cloud Python SDK, you must have an Alibaba Cloud account as well as an AccessKey.
The AccessKey is required when initializing
AcsClient. 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 Python 3.7.x and above.
Alibaba Cloud Python SDK supports Python 3.7.x and above. 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 named
pip. 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
Import the required modules as follows:
fromaliyunsdkcore.clientimportAcsClientfromaliyunsdkcore.acs_exception.exceptionsimportClientExceptionfromaliyunsdkcore.acs_exception.exceptionsimportServerExceptionfromaliyunsdkecs.request.v20140526importDescribeInstancesRequestfromaliyunsdkecs.request.v20140526importStopInstanceRequest
Initialize the
AcsClientinstance:client=AcsClient("<access-key-id>","<access-key-secret>","<region-id>")
where:
access-key-idis the Accesskey ID for your account.access-key-secretis the AccessKey secret for your account.region-idis 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.
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
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
To use the functionHTTP DEBUG, you must setDEBUG in your environment variable, the corresponding valuemay besdk orSDK.
The following example shows what theHTTP DEBUG do, which will help you debug your codes.
> GET /databases?RegionId=cn-hangzhou HTTP/1.1> Host : ads.cn-hangzhou.aliyuncs.com> User-Agent : AlibabaCloud (Windows 10;AMD64) Python/3.7.1 Core/2.13.1 python-requests/2.18.1> accept-encoding : *> Accept : application/json> Connection : keep-alive> x-sdk-invoke-type : normal> x-acs-version : 2019-01-22> x-acs-region-id : cn-hangzhou> Date : Thu, 21 Feb 2019 08:00:50 GMT> x-acs-signature-method : HMAC-SHA1> x-acs-signature-version : 1.0> Authorization : acs ...> x-sdk-client : python/2.0.0< HTTP/1.1 503 SERVICE_UNAVAILABLE< Date : Thu, 21 Feb 2019 08:00:50 GMT< Content-Type : application/json; charset=UTF-8< Content-Length : 297< Connection : keep-alive< Access-Control-Allow-Origin : *< Access-Control-Allow-Methods : POST, GET, OPTIONS< Access-Control-Allow-Headers : X-Requested-With, X-Sequence, _aop_secret, _aop_signature< Access-Control-Max-Age : 172800< x-acs-request-id : 670F3D09-F8E7-4144-83C3-B56C35DA35ED< Server : Jetty(7.2.2.v20101205)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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.