DCIDServerSDK
The main entry point for the DCID Backend SDK.
Constructor
import { DCIDServerSDK } from '@dcid/server-sdk';
const sdk = new DCIDServerSDK(config: DCIDServerSDKConfig);Configuration
interface DCIDServerSDKConfig {
apiKey: string;
environment?: 'dev' | 'prod';
timeout?: number;
defaultHeaders?: Record<string, string>;
logger?: Logger;
enableRequestLogging?: boolean;
}Example
const sdk = new DCIDServerSDK({
apiKey: process.env.DCID_API_KEY,
environment: 'prod',
timeout: 30000,
enableRequestLogging: process.env.NODE_ENV !== 'production'
});Token Management
setTokens
Set both access and refresh tokens.
sdk.setTokens(tokens: { accessToken: string; refreshToken: string }): voidsetAuthToken
Set access token.
sdk.setAuthToken(token: string): voidgetAuthToken
Get current access token.
const token = sdk.getAuthToken(): string | nullgetRefreshToken
Get current refresh token.
const token = sdk.getRefreshToken(): string | nullsetRefreshToken
Set refresh token. Available in the PHP SDK.
$sdk->setRefreshToken(string $token): voidModule Access
The SDK provides access to the following modules:
| Module | Access (Node.js/Python) | Access (Go) | Description |
|---|---|---|---|
| Authentication | sdk.auth | sdk.Auth | OTP authentication |
| Identity | sdk.identity | sdk.Identity | Encryption, issuing, IPFS, verification |
| Analytics | sdk.analytics | sdk.Analytics | Session tracking |
See individual module pages for detailed API documentation.