JavaScript SDK
The AstraCollab JavaScript SDK provides a pure JavaScript client for Node.js and browser environments. Perfect for server-side applications, CLI tools, and browser-based file management.Installation
Quick Start
Basic Usage
Node.js Example
API Reference
Constructor
config.apiKey(string, required): Your AstraCollab API keyconfig.baseURL(string, optional): API base URL (defaults tohttps://api.astracollab.app)
File Management
List Files
folderId(string, optional): Folder ID to list files from
Upload File
options.file(File|Blob, required): File to uploadoptions.fileName(string, optional): Custom file nameoptions.folderId(string, optional): Folder to upload tooptions.orgId(string, optional): Organization IDoptions.onProgress(function, optional): Progress callback
Download File
fileId(string, required): ID of the file to download
Get File Details
fileId(string, required): ID of the file
Delete File
fileId(string, required): ID of the file to delete
Folder Management
List Folders
parentFolderId(string, optional): Parent folder ID
Create Folder
name(string, required): Folder nameparentFolderId(string, optional): Parent folder ID
API Key Management
List API Keys
Create API Key
name(string, required): API key name
Revoke API Key
keyId(string, required): API key ID to revoke
Examples
Upload Multiple Files
Progress Tracking
Error Handling
CLI Tool Example
Browser Example
Error Handling
The SDK throws errors for various scenarios:Best Practices
- Environment Variables: Store API keys in environment variables
- Error Handling: Always implement proper error handling
- Progress Tracking: Use progress callbacks for large file uploads
- Rate Limiting: Respect API rate limits in your application
- File Validation: Validate files before upload (size, type, etc.)
Support
Need help with the JavaScript SDK?- Examples: Check our examples page
- API Reference: Browse the complete API documentation
- Support: Email us at [email protected]
- Community: Join our Discord server