Initialization
Updated at:2025-11-11
Confirm Endpoint
Before configuring the endpoint for SDK usage, please refer to the developer guide section on DNS Access Domain Name to understand endpoint-related concepts.
The corresponding information of the service domain name is: dns.baidubce.com
Create a new DnsClient
Create a new DnsClient with AK/SK
Users can refer to the following code to create a new DnsClient to access BOS with AK/SK:
Plain Text
1from baidubce.bce_client_configuration import BceClientConfiguration
2from baidubce.services.dns import dns_client
3from baidubce.auth.bce_credentials import BceCredentials
4 AK = 'your-access-key-id' # User's Access Key ID
5 SK = 'your-secret-access-key' # User's Secret Access Key
6 HOST = 'dns.baidubce.com' # dns openApi service domain name
7# // Initialize a DnsClient
8 config = BceClientConfiguration(credentials=BceCredentials(AK, SK), endpoint=HOST)
9 client = dns_client.DnsClient(config)
10
11# For example, to query the zone list
12 client.list_zone()
In the code above, AK corresponds to the "Access Key ID" in the console, and SK corresponds to the "Access Key Secret" in the console. For the access method, please refer to the Operation Guide for Managing Access Key.
