All Products
Search
Document Center

:PYTHON-SDK

Last Updated:Apr 09, 2018
  • 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).

    1. <Endpoint name="mts-cn-beijing">
    2. <RegionIds>
    3. <RegionId>mts-cn-beijing</RegionId>
    4. </RegionIds>
    5. <Products>
    6. <Product>
    7. <ProductName>Mts</ProductName>
    8. <DomainName>mts.cn-beijing.aliyuncs.com</DomainName>
    9. </Product>
    10. </Products>
    11. </Endpoint>
    • API call example

      The following calls SearchMediaWorkflow as an example.

      1. import json
      2. from aliyunsdkmts.request.v20140618 import SearchMediaWorkflowRequest
      1. def search_media_workflow(clt):
      2. request = SearchMediaWorkflowRequest.SearchMediaWorkflowRequest()
      3. request.set_accept_format('JSON')
      4. response = json.loads(clt.do_action(request))
      5. 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.

      1. from aliyunsdkcore import client
      1. clt = client.AcsClient(access_key_id,
      2. access_key_secret,
      3. 'cn-hangzhou')
      4. 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.

      1. from aliyunsdkcore import client
      1. clt = client.AcsClient(access_key_id,
      2. access_key_secret,
      3. 'mts-cn-beijing')
      4. search_media_workflow(clt)