Node.js SDK

  • This guide will show you the basic methods of the Corlink Node.js SDK. Along with a minimal example of using the Corlink Node.js SDK.

Prerequisites

  • Node.js v18 or later
  • An API key from a Corlink server. - Need One? Join our Discord and open a ticket.

Installation

First, install the @rubynetwork/corlink-sdk-node package if you haven't already installed it in your project

NPM
npm install @rubynetwork/corlink-sdk-node
Yarn
yarn add @rubynetwork/corlink-sdk-node
PNPM
pnpm add @rubynetwork/corlink-sdk-node

Methods

  • Key Definition: A key is a "license key" that is used to verify a user's access to a resource.
MethodDescription
createKeyCreate a new Key
deleteKeyDelete a Key
verifyKeyVerify a Key

Options

  • Options for the Corlink class.
OptionTypeDescriptionRequired
corlinkAPIUrlstringThe URL of the Corlink server.Yes
corlinkAPIKeystringThe API key of the Corlink server.Yes

Examples

  • Minimal example of using Corlink with the Node.js SDK (both CommonJS and ES Modules).
const { Corlink } = require('@rubynetwork/corlink-sdk-node');
//create a new Corlink instance
const corlink = new Corlink({
    corlinkAPIUrl: 'https://corlink.example.com',
    corlinkAPIKey: 'your-api-key',
});

//use any of the methods here ex: createKey
async function createKey() {
    const key = await corlink.createKey();
    console.log(key);
}

createKey();
import { Corlink } from '@rubynetwork/corlink-sdk-node';

//create a new Corlink instance
const corlink = new Corlink({
    corlinkAPIUrl: 'https://corlink.example.com',
    corlinkAPIKey: 'your-api-key',
});

//use any of the methods here ex: createKey
async function createKey() {
    const key = await corlink.createKey();
    console.log(key);
}

createKey();