Skip to content

nvansluis/transip-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TransIP REST API for Node.js

This repository contains the open source Node.js client for the TransIP REST API v6.1.

Software License npm version

Requirements

Installation

npm install transip-nodejs

Usage

We have put some self-explanatory examples in the examples directory, but here is a quick breakdown on how it works. Let's go ahead and initialize the library first. Don't forget to add your private key to private_key.txt and replace <YOUR_USERNAME> with your own username.

CommonJS require syntax:

var fs = require('fs');

const login = '<YOUR_USERNAME>';
const label = 'accesstoken1';

const privateKey = fs.readFileSync('./private_key.txt').toString()

var transip = require('transip-nodejs')(privateKey);

var params = {
  login: login,
  label: label,
  read_only: false,
  experation_time: '30 minutes',
  global_key: false
};

transip.accesstoken.create(params, function(err,response) {
  if (err) {
    return console.log(err);
  }

  if (response.error) {
    return console.log(response);
  }
  else {
    const token = response.token;

    transip.domains.list(token, function(err,response) {
      if (err) {
        return console.log(err);
      }
      else {
        console.log(response);
      }
    });
  }
});

About

nodejs library to interact with TransIP API v6

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published