Environment requirements
Python 2.7+pip
Installation
pip install aliyun-python-sdk-core
pip install aliyun-python-sdk-mts
Multi-region support
Edit the aliyunsdkcore/endpoints.xml file in the site-packages directory ofPython, and add the Beijing region before the last line (
</Endpoints>
)(add other regions in a similar way).<Endpoint name="mts-cn-beijing">
<RegionIds>
<RegionId>mts-cn-beijing</RegionId>
</RegionIds>
<Products>
<Product>
<ProductName>Mts</ProductName>
<DomainName>mts.cn-beijing.aliyuncs.com</DomainName>
</Product>
</Products>
</Endpoint>
API call example
The following calls
SearchMediaWorkflow
as an example.import json
from aliyunsdkmts.request.v20140618 import SearchMediaWorkflowRequest
def search_media_workflow(clt):
request = SearchMediaWorkflowRequest.SearchMediaWorkflowRequest()
request.set_accept_format('JSON')
response = json.loads(clt.do_action(request))
return response
Call examples of APIs in the Hangzhou region
When initializing the client, set RegionId to “cn-hangzhou”. No special configuration is required during the API call.
from aliyunsdkcore import client
clt = client.AcsClient(access_key_id,
access_key_secret,
'cn-hangzhou')
search_media_workflow(clt)
Call examples of APIs in the Beijing region
When initializing the client, set RegionId to “mts-cn-beijing”. No special configuration is required during the API call.
from aliyunsdkcore import client
clt = client.AcsClient(access_key_id,
access_key_secret,
'mts-cn-beijing')
search_media_workflow(clt)