All Products
Search
Document Center

Enterprise Distributed Application Service:Call the EDAS API with the Python SDK

Last Updated:Mar 11, 2026

Enterprise Distributed Application Service (EDAS) provides a Python SDK that you can use to manage EDAS resources programmatically. This guide covers SDK installation, authentication setup, and making API calls.

Prerequisites

Before you begin, make sure that you have:

  • Python 2.7.x or later. The code examples in this guide use Python 3 syntax (f-strings require Python 3.6 or later). For Python 2.7.x syntax adjustments, see Python version compatibility

  • An Alibaba Cloud account with an AccessKey ID and AccessKey secret. For security, use a Resource Access Management (RAM) user instead of your root account

Install the SDK

The EDAS Python SDK consists of two packages:

PackageDescription
aliyun-python-sdk-coreCore library for authentication and HTTP requests
aliyun-python-sdk-edasEDAS-specific library with API request and response classes

Install with pip (recommended)

Set up a virtual environment, then install both packages:

pip install -U aliyun-python-sdk-core
pip install -U aliyun-python-sdk-edas
Note

On Linux, run these commands as the root user. On macOS, prefix each command with sudo. To keep the SDK up to date, re-run these commands every two to three months.

Verify the installation

After installation, check the installed versions:

pip list 2>/dev/null | grep -E "aliyun-python-sdk-core|aliyun-python-sdk-edas"

Expected output (version numbers may vary):

aliyun-python-sdk-core        2.13.9
aliyun-python-sdk-edas        2.52.1

Install offline

If the target machine has no internet access:

  1. On a machine with internet access, download the SDK for Python core library from Alibaba Cloud Open Platform.

  2. Transfer the downloaded package to the target machine, extract it, and install each SDK from its directory:

       # Install the core library
       cd aliyun-python-sdk-core
       python setup.py install
    
       # Install the EDAS library
       cd aliyun-python-sdk-edas
       python setup.py install

Configure authentication

Set your AccessKey ID and AccessKey secret as environment variables to avoid hardcoding credentials in source code.

export ALIBABA_CLOUD_ACCESS_KEY_ID=<your-access-key-id>
export ALIBABA_CLOUD_ACCESS_KEY_SECRET=<your-access-key-secret>
PlaceholderDescription
<your-access-key-id>AccessKey ID of your Alibaba Cloud or RAM user account
<your-access-key-secret>AccessKey secret of your Alibaba Cloud or RAM user account

Make your first API call

This example initializes the SDK client and calls ListApplication to list all applications in a region.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import json
from aliyunsdkcore.client import AcsClient
from aliyunsdkedas.request.v20170801.ListApplicationRequest import ListApplicationRequest

# Load credentials from environment variables
access_key_id = os.environ.get("ALIBABA_CLOUD_ACCESS_KEY_ID")
access_key_secret = os.environ.get("ALIBABA_CLOUD_ACCESS_KEY_SECRET")

# Set the region where your EDAS resources are deployed
region_id = "<region-id>"  # Example: cn-shanghai

# Initialize the SDK client
client = AcsClient(
    ak=access_key_id,
    secret=access_key_secret,
    region_id=region_id,
    timeout=300
)

# Call the ListApplication API
request = ListApplicationRequest()
response = json.loads(client.do_action_with_exception(request))

# Check the response
if response["Code"] == 200:
    apps = response["ApplicationList"]["Application"]
    for app in apps:
        print(f'Application: {app["Name"]} (ID: {app["AppId"]})')
else:
    print(f'Request failed with code: {response["Code"]}')

Replace <region-id> with the region of your EDAS resources, for example, cn-shanghai. This region must match the Elastic Compute Service (ECS) instances, Server Load Balancer (SLB) instances, and virtual private clouds (VPCs) associated with your applications.

List deploy groups for each application

After you verify basic connectivity, you can extend the example to list all applications along with their deploy groups.

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import json
from aliyunsdkcore.client import AcsClient
from aliyunsdkedas.request.v20170801.ListApplicationRequest import ListApplicationRequest
from aliyunsdkedas.request.v20170801.ListDeployGroupRequest import ListDeployGroupRequest

# Load credentials from environment variables
access_key_id = os.environ.get("ALIBABA_CLOUD_ACCESS_KEY_ID")
access_key_secret = os.environ.get("ALIBABA_CLOUD_ACCESS_KEY_SECRET")

# Set the region where your EDAS resources are deployed
region_id = "<region-id>"  # Example: cn-shanghai

# Initialize the SDK client
client = AcsClient(
    ak=access_key_id,
    secret=access_key_secret,
    region_id=region_id,
    timeout=300
)

# Step 1: List all applications
app_request = ListApplicationRequest()
app_response = json.loads(client.do_action_with_exception(app_request))

if app_response["Code"] == 200:
    apps = app_response["ApplicationList"]["Application"]
    for app in apps:
        app_name = app["Name"]
        app_id = app["AppId"]
        print(f"Application: {app_name} (ID: {app_id})")

        # Step 2: List deploy groups for each application
        dg_request = ListDeployGroupRequest()
        dg_request.set_AppId(app_id)
        dg_response = json.loads(client.do_action_with_exception(dg_request))

        if dg_response["Code"] == 200:
            groups = dg_response["DeployGroupList"]["DeployGroup"]
            for group in groups:
                group_name = group["GroupName"]
                # _DEFAULT_GROUP is the system-generated default group
                if group_name == "_DEFAULT_GROUP":
                    group_name = "Default group"
                print(f"  Group: {group_name} (ID: {group['GroupId']})")
        else:
            print(f"  Failed to get deploy groups: code {dg_response['Code']}")
else:
    print(f"Failed to get applications: code {app_response['Code']}")

Automatic endpoint resolution

Starting from aliyun-python-sdk-core 2.13.9 and aliyun-python-sdk-edas 2.52.1, the SDK automatically resolves the endpoint based on region_id. You no longer need to set product_name (for example, Edas) or region_domain (for example, edas.cn-shanghai.aliyuncs.com) manually.

To use automatic endpoint resolution, update both packages to their latest versions:

pip install -U aliyun-python-sdk-core
pip install -U aliyun-python-sdk-edas

Python version compatibility

The code examples in this guide use Python 3 syntax. If you use Python 2.7.x, replace the print calls with Python 2 syntax, for example, print u'text' instead of print(f'text').

See also