Installation¶
This guide will help you get started with the 5N ID SDK or REST API integration.
Prerequisites¶
Before you begin, you'll need:
- Client Credentials: Request access to the 5N ID service to obtain:
- Client ID
-
Client Secret
-
Network Selection: Choose your environment:
devnet- For development and testing-
mainnet- For production use -
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¶
yarn¶
bun¶
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:
- Obtain an Access Token: Use OAuth2
client_credentialsflow
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"
- 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:
- Client sends credentials to the token endpoint
- Server returns an access token
- Client includes the token in the
Authorizationheader:Bearer <token> - Token expires after a set period (typically 1 hour)
- SDK automatically refreshes tokens; REST API users must handle refresh manually
Next Steps¶
- API Reference - Learn about available REST API endpoints
- SDK Reference - Explore SDK methods and usage
- Examples - See code examples and integration patterns