Skip to main content

DNSimple API service for python

Project description

DNSimple Python Client

A Python client for the DNSimple API v2.

CI

Documentation

Requirements

  • Python 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.

Installation

Where <version> denotes the version of the client you want to install.

To install the latest version:

pip install dnsimple

To install a specific version:

pip install dnsimple==2.0.1

Usage

This library is a Python client you can use to interact with the DNSimple API v2. Here are some examples.

from dnsimple import Client

client = Client(access_token='a1b2c3')

# Fetch your details
response = client.identity.whoami()             # execute the call
data = response.data                            # extract the relevant data from the response or
account = client.identity.whoami().data.account # execute the call and get the data in one line

Sandbox Environment

We highly recommend testing against our sandbox environment before 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 the base_url option when you construct the client:

from dnsimple import Client

client = Client(base_url='https://api.sandbox.dnsimple.com', access_token="a1b2c3")

You can also set the sandbox environment like so:

from dnsimple import Client

client = 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 will not work in the sandbox environment.

Define an account ID

from dnsimple import Client

client = 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 token
whoami = client.identity.whoami().data
account_id = whoami.account.id

List your domains

from dnsimple import Client

client = Client(access_token='a1b2c3')

account_id = client.identity.whoami().data.account.id
domains = 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 date
client.domains.list_domains(account_id, filter={'name_like': 'example'}).data    # Domains from the 1010 account filtered by the domain name name

Create a domain

from dnsimple import Client

client = Client(access_token='a1b2c3')

account_id = client.identity.whoami().data.account.id
response = client.domains.create_domain(account_id, 'example.com')
domain = response.data # The newly created domain

Get a domain

from dnsimple import Client

client = Client(access_token='a1b2c3')

account_id = client.identity.whoami().data.account.id
domain_id = client.domains.list_domains(account_id).data[0].id
domain = client.domains.get_domain(account_id, domain_id).data # The domain you are looking for

Setting a custom User-Agent header

You customize the User-Agent header for the calls made to the DNSimple API:

from dnsimple import Client

client = Client(user_agent="my-app")

The value you provide will be appended to the default User-Agent the client uses. For example, if you use my-app, the final header value will be my-app dnsimple-python/0.1.0 (note that it will vary depending on the client version).

Contributing

Contibutions are welcomed. Please open an issue to discuss the changes before opening a PR. For more details on how to do development please refer to CONTRIBUTING.md

License

Copyright (c) 2022 DNSimple Corporation. This is Free Software distributed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dnsimple-2.15.0.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

dnsimple-2.15.0-py3-none-any.whl (47.0 kB view details)

Uploaded Python 3

File details

Details for the file dnsimple-2.15.0.tar.gz.

File metadata

  • Download URL: dnsimple-2.15.0.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.8.18 Linux/6.5.0-1015-azure

File hashes

Hashes for dnsimple-2.15.0.tar.gz
Algorithm Hash digest
SHA256 1946f40205bc22717493c64ab8566b04ce9d6e8ac3c5a5454130364b22351bfb
MD5 cd0e18293f1d5d79e4246d1b3eb281ad
BLAKE2b-256 9e0f7ccb3ed8e71bf2aac07e92d4513e3ebe2926ee1af3ba6a44332102adbdf8

See more details on using hashes here.

File details

Details for the file dnsimple-2.15.0-py3-none-any.whl.

File metadata

  • Download URL: dnsimple-2.15.0-py3-none-any.whl
  • Upload date:
  • Size: 47.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.8.18 Linux/6.5.0-1015-azure

File hashes

Hashes for dnsimple-2.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0754536892b06ec6c3026eec6482b2d087a73ebad8111d15d24536a108e90e11
MD5 1ceb2f56a2e86ff644e224fd816ddcfe
BLAKE2b-256 fec4492c921f0c1eee0009bb5580018fd8858b4c82a1ecc92374ee977c1d2a01

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page