Git Product home page Git Product logo

dnsimple-node's Introduction

DNSimple Node.JS Client

A Node.JS client for the DNSimple API v2.

Build Status js-semistandard-style npm version npm downloads

Requirements

The dnsimple-node package requires node 10.0.0 or higher.

You must also have an activated DNSimple account to access the DNSimple API.

Installation

You can install this package directly from the github repo with npm install dnsimple/dnsimple-node.

Alternatively, install the latest stable version from NPM with npm install dnsimple.

Usage

This library is a nodejs client you can use to interact with the DNSimple API v2.

Note that in all examples below, the accessToken must be an OAuth token as described in the DNSimple API Access Token documentation.

The DNSimple nodejs library uses promises exclusively, thus all client calls that call out to the DNSimple API will return a Promise. The examples below demonstrate basic usage.

"use strict";

var client = require("dnsimple")({
  accessToken: process.env.TOKEN,
});

// Fetch your details
client.identity.whoami().then(function(response) {
  console.log(response.data);
}, function(error) {
  console.log(error);
});

// List your domains
var accountId = "1010";
client.domains.listDomains(accountId).then(function(response) {
  console.log(response.data);
}, function(error) {
  console.log(error);
});

client.domains.listDomains(accountId, { page: 3 }).then(function(response) {
  console.log(response.data);
}, function(error) {
  console.log(error);
});

// Create a domain
client.domains.createDomain(accountId, { name: "example.com" }).then(function(response) {
  console.log(response.data);
}, function(error) {
  console.log(error);
});

// Get a domain
client.domains.getDomain(accountId, "example.com").then(function(response) {
  console.log(response.data);
}, function(error) {
  console.log(error);
});

To be run like this:

TOKEN=[TOKEN VALUE GOES HERE] node test.js

Take a look at https://github.com/dnsimple/hello-domains-node for an example app that authorizes via OAuth and displays your domain list.

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:

var client = require('dnsimple')({
  baseUrl: 'https://api.sandbox.dnsimple.com',
  accessToken: process.env.TOKEN,
});

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:

var client = require('dnsimple')({
  user_agent: 'my-app',
  accessToken: process.env.TOKEN,
});

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 dnsimple-node/x.x.x my-app (note that it will vary depending on the client version).

License

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

dnsimple-node's People

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.