An endpoint is the address of the API server of an Alibaba Cloud service. Alibaba Cloud SDK has a built-in endpoint addressing module. After a request is sent, Alibaba Cloud SDK will find the endpoint to use according to the region ID and product ID that are specified when creating a client.

Automatic addressing

Each service may have different endpoints in different regions. For example, the endpoint of an ECS instance in China (Hangzhou) is ecs.cn-hangzhou.aliyuncs.com, but the endpoint is ecs.ap-northeast-1.aliyuncs.com if the ECS instance is located in Japan (Tokyo).

You must specify a region ID while initializing an AcsClient object. An endpoint is returned based on the specified region ID and service name. For example, if the region ID of the client that is created by using the ECS SDK is set to cn-hangzhou, the endpoint is ecs.cn-hangzhou.aliyuncs.com.

Note You cannot change the sequence of the parameters. Enter AccessKey ID, then AccessKey Secret, and finally Region ID.
client = AcsClient(
    "<your-access-key-id>",
    "<your-access-key-secret>",
    "<your-region-id>"   # Note the sequence of the parameters. The third parameter is Region ID.
);

Configure an endpoint

Refer to the following code to configure an endpoint for a request to use. For more information about available endpoints, see the API reference of each service.
Notice Replace the endpoint (ecs.cn-hangzhou.aliyuncs.com) in the sample code with the actual endpoint.
$request = new DescribeInstancesRequest();
# Configure an endpoint for this request.
request.set_endpoint("ecs.cn-hangzhou.aliyuncs.com")
# Use the configured endpoint to initiate a request.
response = self.client.do_action_with_exception(request)

Handle exceptions

If an error occurs, such as SDK.InvalidRegionID or SDK.EndpointResolvingError, refer to the following solutions to troubleshoot.
Error code Error message Solution
SDK.InvalidRegionID can not find endpoint to access The current SDK version is earlier than required. Upgrade the SDK core library aliyun-python-sdk-core to version 2.9.0 or later.
SDK.EndpointResolvingError No such region <region-id>. Please check your region ID. Make sure that the region ID that you entered is correct.

You can call DescribeRegions to query the region ID.

SDK.EndpointResolvingError No endpoint for product <product-id>. Solution:
  • The current SDK version is earlier than required. Upgrade the SDK core library aliyun-python-sdk-core to version 2.9.0 or later, and upgrade the service SDK such as aliyun-java-sdk-ecs to the latest version.
  • Configure the endpoint directly to send requests. For more information, see Configure an endpoint.
SDK.EndpointResolvingError No endpoint in the region <region-id> for product <product-id>. The endpoint of the service cannot be found in the specified region. Solution:
  • The service may not be available in the specified region. Change the region ID as instructed.
  • Upgrade the SDK core library aliyun-python-sdk-core to the latest version to apply the latest built-in endpoint resolution configurations. Alibaba Cloud will release new versions of the SDK core library whenever service endpoints are added or changed.
  • Configure the endpoint directly to send requests. For more information, see Configure an endpoint.