GithubHelp home page GithubHelp logo

isabella232 / dnsimple-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dnsimple/dnsimple-python

0.0 0.0 0.0 320 KB

The DNSimple API client for Python.

Home Page: https://developer.dnsimple.com

License: MIT License

Python 99.67% Makefile 0.33%

dnsimple-python's Introduction

โš ๏ธ Development Warning

This project targets the development of the API client for the DNSimple API v2.

This version is currently under development, therefore the methods and the implementation should he considered a work-in-progress. Changes in the method naming, method signatures, public or internal APIs may happen at any time.

The code is tested with an automated test suite connected to a continuous integration tool, therefore you should not expect bugs to be merged into master. Regardless, use this library at your own risk.

DNSimple Python Client

A Python client for the DNSimple API v2.

Build Status

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

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

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.

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).

License

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

dnsimple-python's People

Contributors

dcrosta avatar dependabot-preview[bot] avatar deviatefish avatar digitronik avatar drcapulet avatar drpotato avatar dxtimer avatar ecomba avatar jmurty avatar joshbrooks avatar kevchentw avatar lcd1232 avatar mdippery avatar mherrmann avatar mikemaccana avatar mjacksonw avatar onlyhavecans avatar philhagen avatar pkaeding avatar pwnall avatar pztrick avatar reagent avatar weppos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.