Skip to content

Installation

This guide will help you get started with the 5N ID SDK or REST API integration.

Prerequisites

Before you begin, you'll need:

  1. Client Credentials: Request access to the 5N ID service to obtain:
  2. Client ID
  3. Client Secret

  4. Network Selection: Choose your environment:

  5. devnet - For development and testing
  6. mainnet - For production use

  7. Node.js Environment (for SDK): If using the SDK, ensure you have Node.js 16+ installed

SDK Installation

Install the 5N ID SDK using your preferred package manager:

npm

npm install @fivenorth/id-sdk

yarn

yarn add @fivenorth/id-sdk

bun

bun add @fivenorth/id-sdk

Initialization

SDK Initialization

After installing the package, initialize the SDK connection:

import { idSdk } from '@fivenorth/id-sdk';

// Connect to devnet
const connection = await idSdk.connect({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  network: 'devnet' // or 'mainnet' for production
});

// If network is not specified, it defaults to 'mainnet'
const mainnetConnection = await idSdk.connect({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret'
});

REST API Setup

For REST API integration, you'll need to:

  1. Obtain an Access Token: Use OAuth2 client_credentials flow
curl -X POST https://id.devnet.cantonloop.com/oauth/token \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=your-client-id" \
  -d "client_secret=your-client-secret"
  1. Use the Token: Include the access token in subsequent API requests
curl -X GET https://id.devnet.cantonloop.com/api/v1/credentials \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Environment Configuration

Base URLs

  • Devnet: https://id.devnet.cantonloop.com
  • Mainnet: https://id.mainnet.cantonloop.com (or your mainnet URL)

API Versioning

The API uses versioning in the path. Current version is v1:

  • /api/v1/credentials
  • /api/v1/credentials/:partyId
  • etc.

Authentication

Both SDK and REST API use OAuth2 client_credentials flow:

  1. Client sends credentials to the token endpoint
  2. Server returns an access token
  3. Client includes the token in the Authorization header: Bearer <token>
  4. Token expires after a set period (typically 1 hour)
  5. SDK automatically refreshes tokens; REST API users must handle refresh manually

Next Steps