A simple service for managing a dnsimple account.
- Python 2.7
Other than the base /
endpoint, all endpoints are managed via JWT Token Authentication.
To create JWT tokens for configured users, run the following:
python token-generator
For users who have deployed to Heroku, run the following instead:
# replace 'APP_NAME' with your heroku application's name
heroku --app APP_NAME run python token-generator
You can then use the resulting json-web-token to make requests to the api:
# replace JWT_TOKEN with your generated token
curl -X POST -H "Authorization: Bearer JWT_TOKEN" http://localhost:8000/whoami
Tokens do not expire, and are stable across installations so long as the SECRET_KEY
environment variable is the same. To expire all tokens, simply change the SECRET_KEY
to a new value.
Other than the Authorization
header, dns-api
endpoints only depend on the HTTP Method
and the path to make changes. This is to simplify cli usage.
You may also optionally use the endpoints that require posting json data for creating or updating records.
All examples use the following base url: http://localhost:8000
Returns an endpoint that can be used for making HTTP-based healthchecks.
curl \
-X GET \
http://localhost:8000/
- headers:
Authorization
: Required
Returns the currently authenticated user.
curl \
-X GET \
-H "Authorization: Bearer JWT_TOKEN" \
http://localhost:8000/whoami
- headers:
Authorization
: Required
Returns a list of domains that can be managed, as well as blacklisted subdomains.
curl \
-X GET \
-H "Authorization: Bearer JWT_TOKEN" \
http://localhost:8000/domains
- headers:
Authorization
: Required
- path:
record_id
: Adns-api
record id
Returns a single dns record.
curl \
-X GET \
-H "Authorization: Bearer JWT_TOKEN" \
http://localhost:8000/records/1
Create a new record.
- headers:
Authorization
: RequiredContent-Type
: Required. Value:application/json
- json data:
domain_type
: Options: [A
,CNAME
]. Case-insensitivedomain
: A domain managed bydns-api
subdomain
: A valid subdomain. Currently only alphanumeric values are allowed.to
: A endpoint to point theA
record orCNAME
.
Creates an A
or CNAME
record for the specified path.
curl \
-X POST \
-H "Authorization: Bearer JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"domain_type": "cname", "domain": "example.com", "subdomain": "api", "to": "api.example.org"}' \
http://localhost:8000/records
Replace the to
value for a specified record.
- headers:
Authorization
: RequiredContent-Type
: Required. Value:application/json
- json data:
to
: A endpoint to point theA
record orCNAME
.
- path:
record_id
: Adns-api
record id
Creates an A
or CNAME
record for the specified path.
curl \
-X POST \
-H "Authorization: Bearer JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"to": "api.example.org"}' \
http://localhost:8000/records/1
Delete the specified record.
- headers:
Authorization
: Required
- path:
record_id
: Adns-api
record id
Deletes the specified dns record.
curl \
-X DELETE \
-H "Authorization: Bearer JWT_TOKEN" \
http://localhost:8000/records/1
Create or update a record specified by path.
- headers:
Authorization
: Required
- path:
domain_type
: Options: [A
,CNAME
]. Case-insensitivedomain
: A domain managed bydns-api
subdomain
: A valid subdomain. Currently only alphanumeric values are allowed.to
: A endpoint to point theA
record orCNAME
.
Creates an A
or CNAME
record for the specified path.
curl \
-X POST \
-H "Authorization: Bearer JWT_TOKEN" \
http://localhost:8000/records/cname/example.com/api/api.example.org
Delete a record specified by path.
- headers:
Authorization
: Required
- path:
domain_type
: Options: [A
,CNAME
]. Case-insensitivedomain
: A domain managed bydns-api
subdomain
: A valid subdomain. Currently only alphanumeric values are allowed.
Deletes an A
or CNAME
record on the specified path.
curl \
-X DELETE \
-H "Authorization: Bearer JWT_TOKEN" \
http://localhost:8000/records/cname/example.com/api