Package: dnsimple
DNSimple Python ClientA Python client for theDNSimple API v2.Documentationdnsimple PyPIDNSimple API documentationDNSimple API examples repositoryDNSimple support documentationRequirementsPython 3.8+ (PyPy supported) - Note later versions of Python may be supported, but we make no guarantees as they are not tracked in our CI.InstallationWhere<version>denotes the version of the client you want to install.To install the latest version:pipinstalldnsimpleTo install a specific version:pipinstalldnsimple==2.0.1UsageThis library is a Python client you can use to interact with theDNSimple API v2. Here are some examples.fromdnsimpleimportClientclient=Client(access_token='a1b2c3')# Fetch your detailsresponse=client.identity.whoami()# execute the calldata=response.data# extract the relevant data from the response oraccount=client.identity.whoami().data.account# execute the call and get the data in one lineSandbox EnvironmentWe highly recommend testing against oursandbox environmentbefore using our
production environment. This will allow you to avoid real purchases, live charges on your credit card, and reduce the
chance of your running up against rate limits.The client supports both the production and sandbox environment. To switch to sandbox pass the sandbox API host using
thebase_urloption when you construct the client:fromdnsimpleimportClientclient=Client(base_url='https://api.sandbox.dnsimple.com',access_token="a1b2c3")You can also set the sandbox environment like so:fromdnsimpleimportClientclient=Client(sandbox=True,access_token='a1b2c3')You will need to ensure that you are using an access token created in the sandbox environment.
Production tokens willnotwork in the sandbox environment.Define an account IDfromdnsimpleimportClientclient=Client(access_token='a1b2c3')account_id=1010# You can also fetch it from the whoami response# as long as you authenticate with an Account access tokenwhoami=client.identity.whoami().dataaccount_id=whoami.account.idList your domainsfromdnsimpleimportClientclient=Client(access_token='a1b2c3')account_id=client.identity.whoami().data.account.iddomains=client.domains.list_domains(account_id).data# Domains from the 1010 account (first page)client.domains.list_domains(account_id,sort='expires_on:asc').data# Domains from the 1010 account in ascending order by domain expiration dateclient.domains.list_domains(account_id,filter={'name_like':'example'}).data# Domains from the 1010 account filtered by the domain name nameCreate a domainfromdnsimpleimportClientclient=Client(access_token='a1b2c3')account_id=client.identity.whoami().data.account.idresponse=client.domains.create_domain(account_id,'example.com')domain=response.data# The newly created domainGet a domainfromdnsimpleimportClientclient=Client(access_token='a1b2c3')account_id=client.identity.whoami().data.account.iddomain_id=client.domains.list_domains(account_id).data[0].iddomain=client.domains.get_domain(account_id,domain_id).data# The domain you are looking forSetting a customUser-AgentheaderYou customize theUser-Agentheader for the calls made to the DNSimple API:fromdnsimpleimportClientclient=Client(user_agent="my-app")The value you provide will be appended to the defaultUser-Agentthe client uses.
For example, if you usemy-app, the final header value will bemy-app dnsimple-python/0.1.0(note that it will vary depending on the client version).ContributingContibutions are welcomed. Please open an issue to discuss the changes before opening a PR. For more details on how to do development please refer toCONTRIBUTING.mdLicenseCopyright (c) 2022 DNSimple Corporation. This is Free Software distributed under the MIT license.