Fully-typed TypeScript client library for the DUAL Platform API v3. Provides 102 methods across 14 modules with built-in retry logic, error handling, and automatic token management.
- 102 API Methods across 14 modules
- Fully Typed TypeScript interfaces and classes
- Automatic Retry Logic with exponential backoff
- Token Management with JWT bearer authentication
- Request Timeout configuration
- Zero Dependencies for production (TypeScript only)
- Modular Organization with focused domain modules
npm install @dual/sdk
# or
yarn add @dual/sdkimport { DualClient, DualConfig } from '@dual/sdk';
const client = new DualClient({
token: 'your-jwt-token',
baseUrl: 'https://blockv-labs.io',
timeout: 30000,
retry: {
maxAttempts: 3,
backoffMs: 1000
}
});
// Get current wallet
const wallet = await client.wallets.getCurrentWallet();
console.log(wallet);
// List templates
const templates = await client.templates.listTemplates();
// List objects with pagination
const objects = await client.objects.listObjects({ limit: 10 });The SDK is organized into 14 focused modules:
getPaymentConfig()- Retrieve payment configurationlistDeposits()- List all deposits
requestAccess()- Request access to a featurelistSupportMessages()- Retrieve support messagessendSupportMessage()- Send a support messagegetSupportMessage()- Retrieve a specific message
listOrganizations()- List all organizationscreateOrganization()- Create new organizationgetOrganization()- Get organization detailsupdateOrganization()- Update organizationgetOrganizationBalance()- Get balancegetBalanceHistory()- Get balance historylistMembers()- List membersaddMember()- Add memberremoveMember()- Remove memberupdateMemberRole()- Update member rolelistRoles()- List rolescreateRole()- Create roleupdateRole()- Update roledeleteRole()- Delete rolecreateInvitation()- Create invitationlistInvitations()- List invitationsdeleteInvitation()- Delete invitationacceptInvitation()- Accept invitation
executeAction()- Execute an actionlistActions()- List available actionsgetAction()- Get action detailsexecuteBatchActions()- Execute batch actionslistActionTypes()- List action typescreateActionType()- Create action typegetActionType()- Get action type detailsupdateActionType()- Update action type
login()- Login with walletguestLogin()- Guest loginrequestResetCode()- Request password resetverifyResetCode()- Verify reset coderegister()- Register new walletverifyRegistration()- Verify registrationgetCurrentWallet()- Get current walletupdateCurrentWallet()- Update current walletdeleteCurrentWallet()- Delete current walletgetLinkedWallets()- Get linked walletsgetWalletById()- Get wallet by IDgetLinkedWalletsById()- Get linked wallets by IDlinkWallet()- Link walletrefreshToken()- Refresh access token
listApiKeys()- List API keyscreateApiKey()- Create API keydeleteApiKey()- Delete API key
listTemplates()- List templatescreateTemplate()- Create templategetTemplate()- Get templateupdateTemplate()- Update templatedeleteTemplate()- Delete templatelistVariations()- List template variationscreateVariation()- Create template variation
listObjects()- List objectsgetObject()- Get objectupdateObject()- Update objectgetObjectChildren()- Get object childrengetObjectParents()- Get object parentsgetObjectActivity()- Get object activitygetObjectsByGeo()- Get objects by geo locationsearchObjects()- Search objectscountObjects()- Count objects
listFaces()- List facescreateFace()- Create facegetFace()- Get faceupdateFace()- Update facedeleteFace()- Delete facegetFacesByTemplate()- Get faces by template
uploadFile()- Upload filegetFile()- Get filedeleteFile()- Delete filegetTemplateAssets()- Get template assetsuploadTemplateAsset()- Upload template asset
listMessages()- List messagessendMessage()- Send messagelistMessageTemplates()- List message templatesgetMessageTemplate()- Get message templatecreateMessageTemplate()- Create message templateupdateMessageTemplate()- Update message templatedeleteMessageTemplate()- Delete message template
listWebhooks()- List webhookscreateWebhook()- Create webhookgetWebhook()- Get webhookupdateWebhook()- Update webhookdeleteWebhook()- Delete webhooktestWebhook()- Test webhook
listBatches()- List batchesgetBatch()- Get batchlistCheckpoints()- List checkpointsgetCheckpoint()- Get checkpoint
listPublicTemplates()- List public templatesgetPublicTemplate()- Get public templategetPublicObject()- Get public objectsearchPublicObjects()- Search public objectsgetPublicFacesByTemplate()- Get public faces by templategetPublicOrganization()- Get public organizationgetPublicStats()- Get public statistics
interface DualConfig {
/** API access token (JWT) */
token?: string;
/** Base URL for API requests */
baseUrl?: string;
/** Request timeout in milliseconds */
timeout?: number;
/** Custom fetch implementation */
fetch?: typeof fetch;
/** Retry configuration */
retry?: {
maxAttempts?: number;
backoffMs?: number;
};
}baseUrl:https://blockv-labs.iotimeout:30000(30 seconds)maxAttempts:3backoffMs:1000
All API errors are thrown as DualError instances:
export class DualError extends Error {
public status: number; // HTTP status code
public code: string; // Error code
public body: any; // Response body
}import { DualClient, DualError } from '@dual/sdk';
try {
await client.wallets.getCurrentWallet();
} catch (error) {
if (error instanceof DualError) {
console.error(`Error [${error.code}]: ${error.status}`);
console.error(error.body);
} else {
console.error('Unknown error:', error);
}
}The SDK uses JWT bearer token authentication by default:
const client = new DualClient({
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
});curl -X POST https://blockv-labs.io/wallets/login \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"password": "password"
}'Response:
{
"token": "eyJhbGc...",
"refreshToken": "refresh_token_here"
}For service-to-service communication, use API keys:
POST /api-keys
Authorization: Bearer <jwt_token>
Content-Type: application/json
{
"name": "My Service"
}Then use the key in requests:
// Pass via config (custom implementation needed)
const client = new DualClient({
token: 'api_key_...'
});The SDK uses cursor-based pagination. Include a cursor parameter in query options:
// First page
const result = await client.objects.listObjects({ limit: 10 });
console.log(result.data);
// Next page
if (result.hasMore) {
const nextPage = await client.objects.listObjects({
cursor: result.cursor,
limit: 10
});
}Response format:
{
"data": [...],
"cursor": "next_cursor_value",
"hasMore": true
}The SDK automatically retries failed requests with exponential backoff:
const client = new DualClient({
retry: {
maxAttempts: 3, // Retry up to 3 times
backoffMs: 1000 // Start with 1s delay, then 2s, 4s, etc.
}
});Configure request timeout in milliseconds:
const client = new DualClient({
timeout: 60000 // 60 seconds
});For the complete API reference, visit: https://dual-docs.vercel.app/docs/developer-kit/sdk
const wallet = await client.wallets.getCurrentWallet();
console.log(wallet);const templates = await client.templates.listTemplates({
limit: 20
});
console.log(templates);const obj = await client.objects.updateObject('object_id', {
properties: { name: 'Updated Name' }
});const results = await client.objects.searchObjects({
query: 'my items',
limit: 50
});const result = await client.ebus.executeAction({
objectId: 'obj_123',
actionType: 'transfer',
target: 'user_456'
});const webhook = await client.webhooks.createWebhook({
url: 'https://myapp.com/webhook',
events: ['object.created', 'object.updated']
});const orgs = await client.organizations.listOrganizations();
console.log(orgs);npm testCompile TypeScript to JavaScript:
npm run buildOutput goes to the dist/ directory with type definitions.
Contributions are welcome! Please ensure:
- Code follows TypeScript best practices
- All methods are properly typed
- Error handling is comprehensive
- Documentation is updated
- Documentation: https://dual-docs.vercel.app
- GitHub Issues: https://github.com/ro-ro-b/dual-sdk/issues
- Discord: https://discord.gg/dual
- dual-cli - Command-line interface
- dual-postman - Postman collection
- dual-openapi - OpenAPI specification
- dual-migration-guide - v2 to v3 migration
- dual-developer-kit - Complete developer kit
MIT - Copyright (c) 2025 DUAL Platform