@ckbox/sdk-node
v2.11.0
Published
CKBox SDK
Maintainers
Readme
CKBox NodeJS SDK
A lightweight JavaScript SDK for interacting with the CKBox API. This package provides easy integration between NodeJS application and CKBox services.
Installation
# Using npm
npm install @ckbox/sdk-node
# Using yarn
yarn add @ckbox/sdk-node
# Using pnpm
pnpm add @ckbox/sdk-nodeGetting Started
To use the CKBox SDK, you'll need to obtain API credentials from your Customer Portal dashboard:
Initialize CKBox instance
import { CKBox } from '@ckbox/sdk-node';
// Configure CKBox
const config = {
accessKey: 'your-access-key',
environmentId: 'your-environment-id',
workspaceId: 'your-workspace-id', // Optional
userId: 'user-id', // Optional
userName: 'User Name', // Optional
role: 'user' // Optional, defaults to 'user'
};
// Initialize the CKBox wrapper
const { uploader, assets } = new CKBox(config);Uploading Files
// Upload a file from a path
const uploadedFile = await uploader.uploadFile('/path/to/image.jpg', {
categoryId: 'category-id', // Optional
folderId: 'folder-id', // Optional
onProgress: (progress) => {
console.log(`Upload progress: ${progress.progress}%`);
}
});
// Upload a buffer
const buffer = Buffer.from('file content');
const uploadedBuffer = await uploader.uploadBuffer(buffer, 'filename.txt', {
categoryId: 'category-id'
});
// Upload a stream
const fileStream = fs.createReadStream('/path/to/file.pdf');
const uploadedStream = await uploader.uploadStream(fileStream, 'file.pdf', fileSize, {
folderId: 'folder-id'
});Managing Assets
// Get a specific asset by ID
const asset = await assets.getAsset('asset-id');
// List assets with pagination
const assetsList = await assets.getAssets({
offset: 0,
limit: 50,
sortBy: 'uploadedAt',
order: 'desc',
categoryId: 'category-id' // Optional filter
});Features
- Simple and intuitive API for interacting with CKBox service
- Secure authentication using JWT tokens
- File upload functionality with progress tracking
- Asset management (fetching and listing assets)
- Comprehensive error handling
- TypeScript support with full type definitions
- Lightweight with minimal dependencies
API Reference
CKBoxConfig
Configuration object for CKBox SDK:
| Property | Type | Required | Description | |----------|------|----------|-------------| | accessKey | string | Yes | The access key available in the Customer Portal dashboard | | environmentId | string | Yes | The environment ID for CKBox instance | | workspaceId | string | No | The workspace ID for the user | | role | 'user' | 'admin' | 'superadmin' | No | The role of the user (defaults to 'user') | | userId | string | No | The user ID for the user | | userName | string | No | The user name for the user | | serviceOrigin | string | No | Base URL for the CKBox service (defaults to 'https://api.ckbox.io') |
Documentation
For more detailed information and examples, please refer to the CKBox documentation.
License
Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved. CKBox is licensed under a commercial license and is protected by copyright law. For more details about available licensing options please contact us at [email protected].
Trademarks CKBox is a trademark of CKSource Holding sp. z o.o. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
