TypeScript SDK for MsgCore - Universal messaging gateway API.
Auto-generated from backend contracts - Do not edit manually
npm install @msgcore/sdk
import { MsgCore } from '@msgcore/sdk';
const gk = new MsgCore({
apiUrl: 'https://api.msgcore.dev',
apiKey: 'msc_live_your_api_key_here',
});
// Send a message
const result = await gk.messages.send({
targets: [{ platformId: 'platform-id', type: 'user', id: '123' }],
content: { text: 'Hello from MsgCore!' },
});
- âś… Full type safety - TypeScript types auto-generated from backend
- âś… Perfect sync - Always matches backend API contracts
- âś… Zero duplication - Single source of truth from contracts
- âś… Error handling - Built-in error types and authentication handling
- âś… Rate limiting - Automatic rate limit detection
// Create messaging API key
await gk.apikeys.create(data);
// List all API keys
await gk.apikeys.list();
// Create first admin user
await gk.auth.signup(data);
// Login with email and password
await gk.auth.login(data);
// Create identity with Discord and Telegram aliases
await gk.identities.create(data);
// List all identities
await gk.identities.list();
// List all project members
await gk.members.list();
// Add a member with admin role
await gk.members.add(data);
// Get latest 50 messages
await gk.messages.list(data);
// Get message statistics
await gk.messages.stats();
// List recent platform logs
await gk.platformLogs.list();
// List logs for specific platform
await gk.platformLogs.get('platformId');
// Add Discord bot
await gk.platforms.create(data);
// List all platforms
await gk.platforms.list();
// Create a simple project
await gk.projects.create(data);
// List all projects
await gk.projects.list();
// Create webhook for all message events
await gk.webhooks.create(data);
// List all webhooks
await gk.webhooks.list();
const gk = new MsgCore({
apiUrl: 'https://api.msgcore.dev',
apiKey: 'msc_live_your_api_key_here',
defaultProject: 'my-project', // optional
});
const gk = new MsgCore({
apiUrl: 'https://api.msgcore.dev',
jwtToken: 'your-jwt-token',
});
import { MsgCoreError, AuthenticationError, RateLimitError } from '@msgcore/sdk';
try {
await gk.messages.send({ ... });
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('Invalid credentials');
} else if (error instanceof RateLimitError) {
console.error('Rate limit exceeded');
} else if (error instanceof MsgCoreError) {
console.error(`API error: ${error.message}`);
}
}
MIT