SDK for JavaScript
Build and manage applications with Elk's powerful JavaScript SDK. Use our APIs directly from your Node.js or browser environments.
Getting Started with Elk SDK
Installation
npm install elk-js-sdk
For browser environments, include the SDK via CDN:
<script src="https://cdn.elk.dev/sdk/v1/elk-sdk.min.js"></script>
Basic Usage
Node.js Example
const Elk = require('elk-js-sdk'); const client = new Elk.Client({ apiKey: 'your-api-token-here', environment: 'staging' }); client.deployments.deploy({ repository: 'github.com/your-org/your-repo', branch: 'main' }).then(response => { console.log('Deployment ID:', response.deployment_id); });
Browser Example
const elk = window.Elk.init({ apiKey: 'your-api-token-here', environment: 'production' }); elk.deployments.list().then(apps => { console.log('Your Apps:', apps); });
Authentication
The SDK supports multiple authentication modes:
Bearer Token
Use this for programmatic access:
new Elk.Client({apiKey: '...'})
OAuth (Coming Soon)
Upcoming browser support for OAuth flows in 2025.
Key Features
TypeSafety
WebSocket Support
Real-time updates and notifications directly in your apps
CLI Integration
Seamless with Elk CLI for deployment workflows
Advanced Usage
Error Handling
elk.deployments.get('invalid-id') .catch(error => { console.error('Status:', error.status); console.error('Message:', error.message); });
Webhooks
elk.webhooks.subscribe('deployment-created', { callbackUrl: 'https://your-app.com/webhooks' });