@vybit/api-sdk
v1.1.1
Published
Developer API SDK for Vybit notification platform
Maintainers
Readme
@vybit/api-sdk
✅ Developer API SDK for programmatic access to the Vybit notification platform.
Overview
The @vybit/api-sdk provides a complete TypeScript/JavaScript SDK for the Vybit Developer API, enabling you to build custom integrations, automation workflows, and notification management tools.
Use this SDK to:
- Manage vybits (notifications) - create, update, delete
- Handle vybit subscriptions (follows)
- Search and manage sounds
- Retrieve notification logs
- Manage access permissions (peeps)
- Monitor API usage and metrics
Installation
npm install @vybit/api-sdkQuick Start
1. Get Your API Key
- Create a Vybit developer account
- Generate an API key from your developer dashboard
- Store your API key securely (use environment variables)
2. Initialize the Client
import { VybitAPIClient } from '@vybit/api-sdk';
const client = new VybitAPIClient({
apiKey: process.env.VYBIT_API_KEY
});3. Make API Calls
// Check API status
const status = await client.getStatus();
console.log('API Status:', status.status);
// Get your profile
const profile = await client.getProfile();
console.log('Account:', profile.name, profile.email);
// List your vybits
const vybits = await client.listVybits({ limit: 10 });
console.log(`You have ${vybits.length} vybits`);
// Create a new vybit (only name is required)
const vybit = await client.createVybit({
name: 'Server Alert',
description: 'Notifications for server errors',
soundKey: 'sound123abc', // Optional - defaults to system sound
triggerType: 'webhook', // Optional - defaults to 'webhook'
access: 'private' // Optional - defaults to 'private'
});
console.log('Created vybit:', vybit.key);
// Search for sounds
const sounds = await client.searchSounds({ search: 'notification', limit: 5 });
sounds.forEach(sound => {
console.log(`${sound.name} - ${sound.key}`);
});Core Features
Vybit Management
// List vybits with pagination and search
const vybits = await client.listVybits({
offset: 0,
limit: 20,
search: 'alert'
});
// Get specific vybit
const vybit = await client.getVybit('vybit123abc');
// Update vybit
await client.updateVybit('vybit123abc', {
name: 'Updated Alert Name',
status: 'on'
});
// Delete vybit
await client.deleteVybit('vybit123abc');Subscription Management
// Browse public vybits
const publicVybits = await client.listPublicVybits({ limit: 10 });
// Subscribe to a vybit
const follow = await client.createVybitFollow({
subscriptionKey: 'sub123abc456'
});
// List your subscriptions
const follows = await client.listVybitFollows();
// Disable a subscription
await client.updateVybitFollow(follow.followingKey, { status: 'off' });
// Unsubscribe
await client.deleteVybitFollow(follow.followingKey);Sound Search
// Search for sounds
const sounds = await client.searchSounds({
search: 'bell',
limit: 10
});
// Get sound details
const sound = await client.getSound('sound123abc');
// Get playback URL (unauthenticated endpoint)
const playUrl = client.getSoundPlayUrl('sound123abc');
console.log('Play sound at:', playUrl);Notification Logs
// List all logs
const logs = await client.listLogs({ limit: 50 });
// Get specific log
const log = await client.getLog('log123abc');
// List logs for a specific vybit
const vybitLogs = await client.listVybitLogs('vybit123abc', {
search: 'error',
limit: 20
});
// List logs for a subscription
const followLogs = await client.listVybitFollowLogs('follow123abc');Access Control (Peeps)
// Invite someone to a private vybit
const peep = await client.createPeep({
vybKey: 'vybit123abc',
email: '[email protected]'
});
// List peeps for a vybit
const peeps = await client.listVybitPeeps('vybit123abc');
// Accept a peep invitation
await client.acceptPeep('peep123abc');
// Remove access
await client.deletePeep('peep123abc');Monitoring & Metrics
// Get usage metrics
const meter = await client.getMeter();
console.log(`Daily usage: ${meter.count_daily} / ${meter.cap_daily}`);
console.log(`Monthly usage: ${meter.count_monthly} / ${meter.cap_monthly}`);
console.log(`Tier: ${meter.tier_id} (Free=0, Bronze=1, Silver=2, Gold=3)`);Rate Limiting
The Developer API enforces the following rate limits per API key:
- 10 requests per second
- 300 requests per minute
- 5,000 requests per hour
Rate limit errors throw a VybitAPIError with status code 429. The SDK automatically includes rate limit information in error messages.
Error Handling
import { VybitAPIError, VybitAuthError, VybitValidationError } from '@vybit/core';
try {
const vybit = await client.createVybit({
name: 'Test Vybit' // Only name is required
});
} catch (error) {
if (error instanceof VybitAuthError) {
console.error('Authentication failed - check your API key');
} else if (error instanceof VybitValidationError) {
console.error('Invalid parameters:', error.message);
} else if (error instanceof VybitAPIError) {
console.error(`API error (${error.statusCode}):`, error.message);
} else {
console.error('Unexpected error:', error);
}
}Environment Management
The SDK connects to the production Vybit API at https://api.vybit.net/v1.
For different environments (development, staging, production), create separate Vybit accounts with their own API keys. This provides better isolation and security.
// Development
const devClient = new VybitAPIClient({
apiKey: process.env.VYBIT_DEV_API_KEY
});
// Production
const prodClient = new VybitAPIClient({
apiKey: process.env.VYBIT_PROD_API_KEY
});TypeScript Support
The SDK is written in TypeScript and includes comprehensive type definitions:
import {
VybitAPIClient,
Vybit,
VybitCreateParams,
VybitFollow,
Sound,
Log,
Peep,
SearchParams
} from '@vybit/api-sdk';
// Full type safety for all API operations
const params: VybitCreateParams = {
name: 'My Vybit' // Only name is required, all other fields are optional
};
const vybit: Vybit = await client.createVybit(params);API Documentation
Complete OpenAPI 3.0 specification available:
- 📋 Spec: docs/openapi/developer-api.yaml
- 📖 Interactive Docs: Open docs/openapi/index.html in browser
The OpenAPI spec provides:
- Complete endpoint documentation with examples
- Request/response schemas
- Code generation for multiple languages
- Postman/Insomnia collection import
Complete API Reference
Status & Utility
getStatus()- Check API healthgetMeter()- Get usage metrics
Profile
getProfile()- Get user profile
Vybits
listVybits(params?)- List vybitsgetVybit(key)- Get vybitcreateVybit(params)- Create vybitupdateVybit(key, params)- Update vybit (PUT)patchVybit(key, params)- Update vybit (PATCH)deleteVybit(key)- Delete vybit
Subscriptions
listPublicVybits(params?)- Browse public vybitsgetPublicVybit(key)- Get public vybit by subscription key
Vybit Follows
listVybitFollows(params?)- List subscriptionsgetVybitFollow(key)- Get subscriptioncreateVybitFollow(params)- Subscribe to vybitupdateVybitFollow(key, params)- Update subscriptiondeleteVybitFollow(key)- Unsubscribe
Sounds
searchSounds(params?)- Search soundsgetSound(key)- Get sound detailsgetSoundPlayUrl(key)- Get sound playback URL
Logs
listLogs(params?)- List all logsgetLog(logKey)- Get log entrylistVybitLogs(vybKey, params?)- List logs for vybitlistVybitFollowLogs(vybFollowKey, params?)- List logs for subscription
Peeps
listPeeps(params?)- List peepsgetPeep(key)- Get peepcreatePeep(params)- Create peep invitationacceptPeep(key)- Accept invitationdeletePeep(key)- Remove peep
Vybit Peeps (Nested)
listVybitPeeps(vybKey)- List peeps for vybitcreateVybitPeep(vybKey, params)- Add peep to vybitupdateVybitPeep(vybKey, key, params)- Update vybit peepdeleteVybitPeep(vybKey, key)- Remove peep from vybit
Related Packages
- @vybit/oauth2-sdk - OAuth 2.0 authentication for user-facing apps
- @vybit/core - Shared utilities and types
License
MIT
