Web SDK
  • Home
  • Overview
  • Getting started
  • References
    • Authentication
    • Account
      • Users
    • Notifications
    • Bookmark
    • 2FA
    • Collection
    • Connection filters
    • Feed
    • File Upload
    • Invite
    • Messaging
    • Payment
    • Reviews
    • Search
    • Verification
      • Supported document type
      • List of expected ISO countries
    • Wallet
      • Withdrawal
  • Tutorial
  • Web API
Powered by GitBook
On this page
  • Installation
  • Get your API keys
  • Initialization
  • Make your first request

Getting started

This section is dedicated to providing a comprehensive guide on installing and setting up the PAKT SDK in your NodeJS project.

PreviousOverviewNextReferences

Last updated 5 months ago

Installation

To use the PAKT SDK, you first need to install it using npm command. To do so, run:

npm install pakt-sdk

or

yarn add pakt-sdk

Get your API keys

Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.

You can access or generate your API key from the control panel tab within Pakt's Command Center. Before attempting to access, ensure you have a paid and deployed Chainsite.

To deploy and activate a chainsite, follow this guide on

Initialization

To initialize, use the following code block:

import PaktSDK from "pakt-sdk";

const apiKey = config.PAKT_SDK_API_KEY;
const configData: PaktConfig = {
  token: apiKey,
  verbose: true,
};

const sdkInit = await PaktSDK.init(configData);
const PaktSDK = require("pakt-sdk");

const apiKey = config.PAKT_SDK_API_KEY;
const configData = {
  token: apiKey,
  verbose: true,
};
const sdkInit = await PaktSDK.init(configData);

Make your first request


Making calls with the PAKT SDK is straightforward. Refer to the code blocks below for examples. The SDK is also typed with the models and includes a default wrapper.ResponseDto<T>.

ResponseDto<T> Is declared as:

interface ResponseDto<T> {
  data: T;
  status: Status;
  message?: string;
  code?: string;
}

//For example, from the initialized sdk, we can log in this way:

const auth: ResponseDto<UserModelDto> = await sdkInit.auth.login();

The above code initializes the PAKT SDK and ensures the Command Centre generates the API Key

Deploying a Pakt Chainsite
.