⚙️
Cloudnode Documentation
API v4
API v4
  • Cloudnode v4 API Docs
  • Quick Start
  • Token Permission Nodes
  • Reference
    • API Reference
      • Account
      • Authentication
Powered by GitBook
On this page
  • Get your API keys
  • Authenticate Request
  • Sample authentication
  • Send your first request
  • Other platforms

Quick Start

Get your API keys

Most endpoints (e.g. those requiring access to your account) require authentication using a token. You can create an API token in your account settings. Your API key will only be shown once, so make sure to record it securely.

Keep your API token secret! In the wrong hands, your API token can be used to gain unlimited, unrestricted access to your account and even delete your account.

We do not permit sharing of your API token with anyone in any way. If you want to share access to the API of a server, add the person as a sub-user and they will be able to create their own token to manage the server.

Authenticate Request

Most endpoints require authentication. Follow this example to authenticate your requests.

Sample authentication

GET https://api.cloudnode.pro/v4/

Token is provided with Authorization: Bearer <YOUR TOKEN>. If authentication fails, you will get either err_unauthorised or err_no_permission. See below for more info.

Headers

Name
Type
Description

Authorization*

string

Bearer token_abc123...

{
    "code": "err_unauthorised",
    "title": "Authentication credentials are missing",
    "message": "You did not provide an API key or it was invalid. Please provide your API key in the Authorization header, using e.g. 'Authorization: Bearer YOUR_API_KEY'"
}
{
    "code": "err_no_permission",
    "title": "No permission",
    "message": "Valid authentication credentials are present, but you do not have the required permissions for this endpoint"
}

To authenticate with a session, send a cookie named session and value the session ID.

We strongly advise you to use tokens instead of sessions as their permissions and expiration can be controlled, whereas sessions grant access to all permissions the account holds and can be virtually infinite.

Send your first request

We recommend using our well-maintained Node.js library or command-line interface for the simplest experience in operating our API.

Library

const apiClient = new ApiClient("<YOUR TOKEN>");

console.log(await apiClient.auth.check());

CLI

cloudnode login --token <YOUR_TOKEN>
cloudnode auth/check
fetch("https://api.cloudnode.pro/v4/auth/check", {
    method: "GET",
    headers: {
        Authorization: "Bearer <YOUR TOKEN>"
    }
})
  .then(response => response.json())
  .then(data => console.log(data));
const xhr = new XMLHttpRequest();
xhr.addEventListener("load", function () {
    const data = JSON.parse(this.responseText);
    console.log(data);
});
xhr.open("GET", "https://cloudnode.pro/v4/auth/check");
xhr.setRequestHeader("Authorization", "Bearer <YOUR TOKEN>");
xhr.send();

We strongly recommend that you use the JavaScript Fetch API instead.

curl -X GET https://api.cloudnode.pro/v4/auth/check -H "Authorization: Bearer <YOUR TOKEN>"
https api.cloudnode.pro/v4/auth/check "Authorization: Bearer <YOUR TOKEN>"

Other platforms

The following are some examples of how you can communicate with our API using other platforms. We only provide limited support for these platforms and we strongly advise you to learn how to work with HTTP requests in your language of choice on your own before using this API.

require 'net/http'
require 'uri'

uri = URI.parse("https://api.cloudnode.pro/v4/auth/check")
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer <YOUR TOKEN>"

req_options = {
  use_ssl: uri.scheme == "https",
}

response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
  http.request(request)
end

# response.code
# response.body
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.cloudnode.pro/v4/auth/check');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization' => 'Bearer <YOUR TOKEN>',
]);

$response = curl_exec($ch);

curl_close($ch);
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

class Main {
    public static void main(String[] args) throws IOException {
        URL url = new URL("https://api.cloudnode.pro/v4/auth/check");
        HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
        httpConn.setRequestMethod("GET");

        httpConn.setRequestProperty("Authorization", "Bearer <YOUR TOKEN>");
	
	InputStream responseStream = httpConn.getResponseCode() / 100 == 2
	    ? httpConn.getInputStream()
	    : httpConn.getErrorStream();
	Scanner s = new Scanner(responseStream).useDelimiter("\\A");
	String response = s.hasNext() ? s.next() : "";
	System.out.println(response);
    }
}
import requests

headers = {
    'Authorization': 'Bearer <YOUR TOKEN>',
}

response = requests.get('https://api.cloudnode.pro/v4/auth/check', headers=headers)
package main

import (
    "fmt"
    "io/ioutil"
    "log"
    "net/http"
)

func main() {
    client := &http.Client{}
    req, err := http.NewRequest("GET", "https://api.cloudnode.pro/v4/auth/check", nil)
    if err != nil {
        log.Fatal(err)
    }
    req.Header.Set("Authorization", "Bearer <YOUR TOKEN>")
    resp, err := client.Do(req)
    if err != nil {
        log.Fatal(err)
    }
    defer resp.Body.Close()
    bodyText, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%s\n", bodyText)
}
extern crate reqwest;
use reqwest::header;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut headers = header::HeaderMap::new();
    headers.insert("Authorization", "Bearer <YOUR TOKEN>".parse().unwrap());

    let client = reqwest::blocking::Client::new();
    let res = client.get("https://api.cloudnode.pro/v4/auth/check")
        .headers(headers)
        .send()?
        .text()?;
    println!("{}", res);

    Ok(())
}
PreviousCloudnode v4 API DocsNextToken Permission Nodes

Last updated 2 years ago

The Fetch API is available client-side by default without additional code. On Node.js, you can import and use .

XHR can be used in older/legacy browsers which do not support the Fetch API. We do not recommend using XHR server-side, although you could, using one of the many available wrappers on .

cloudnode-pro/node-api
Fetch API
node-fetch
XMLHttpRequest
NPM
What is curl?
What is httpie?