Get the 1&1 Cloud Server Node.js SDK

The 1&1 Node.js SDK is a Node.js library designed for interaction with the 1&1 cloud platform over the REST API.

This guide contains instructions on getting started with the library and automating various management tasks available through the 1&1 Cloud Panel UI.

For more information on Node.js, consult our article on how to set Up a Node.js App for a Website With Apache on Ubuntu 16.04.

Table of Contents

Overview

This SDK is a wrapper for the 1&1 REST API written in Node.js. All operations against the API are performed over SSL and authenticated using your 1&1 token key. The Node.js library facilitates the access to the REST API within an instance running on 1&1 platform.

For more information on the 1&1 Cloud Server for Node.js, visit the Community Portal.

Getting Started

Before you begin you will need to have signed up for a 1&1 account. The credentials you create during sign-up will be used to authenticate against the API.

The Node.js Client Library is available on npm. You can install the latest stable version using npm:

Installation

The official Node.js library is available from the 1&1 GitHub account found here.

Authentication

Set the authentication token and create the API client:

oneandone.oneandoneauth("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

Set the url of the API as follows as follows

oneandone.setendpoint("https://cloudpanel-api.1and1.com/v1");

Error Handling

Please note that the 1&1 API always returns the error message in the body of the response, in the testhelper.js there is the method below, check its usages for how to handle errors:

//expectedStatus you pass this parameter to define what is the expected http status code
//response is the parameter returned from the 1&1 response
helper.assertNoError = function (expectedStatus, response, callback) {
    callback(expectedStatus == response.statusCode);
};

Refer to the Examples and Operations sections for additional information.

Comments

Tags: Node.js