TypeScript SDK for MsgCore - Universal messaging gateway API.
Auto-generated from backend contracts - Do not edit manually
npm install @msgcore/sdkimport { MsgCore } from '@msgcore/sdk';
const msc = new MsgCore({
apiUrl: 'https://api.msgcore.dev',
apiKey: 'msc_live_your_api_key_here',
defaultProject: 'my-project', // optional: sets default project for all operations
});
// Send a message
const result = await msc.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
// Usage example
await msc.analysisEntities.list();// Usage example
await msc.analysisEntities.get('id');// Get all supported models
await msc.analysisModels.list();// Create an analysis profile
await msc.analysisProfiles.create(data);// List all profiles
await msc.analysisProfiles.list();// Run analysis on specific chats
await msc.analysisRuns.create(data);// Get run statistics
await msc.analysisRuns.stats();// Create a sentiment analysis schema
await msc.analysisSchemas.create(data);// List all entity schemas
await msc.analysisSchemas.list();// Create messaging API key
await msc.apikeys.create(data);// List all API keys
await msc.apikeys.list();// Create first admin user
await msc.auth.signup(data);// Login with email and password
await msc.auth.login(data);// Usage example
await msc.chats.list(data);// Usage example
await msc.chats.get('chatId');// Create identity with Discord and Telegram aliases
await msc.identities.create(data);// List all identities
await msc.identities.list();// List all project members
await msc.members.list();// Add a member with admin role
await msc.members.add(data);// Get all messages (sent + received)
await msc.messages.list(data);// Get message statistics
await msc.messages.stats();// List recent platform logs
await msc.platformLogs.list();// List logs for specific platform
await msc.platformLogs.get('platformId');// Add Discord bot
await msc.platforms.create(data);// List all platforms
await msc.platforms.list();// Create a simple project
await msc.projects.create(data);// List all projects
await msc.projects.list();// Create webhook for all message events
await msc.webhooks.create(data);// List all webhooks
await msc.webhooks.list();const msc = new MsgCore({
apiUrl: 'https://api.msgcore.dev',
apiKey: 'msc_live_your_api_key_here',
defaultProject: 'my-project', // optional
});const msc = new MsgCore({
apiUrl: 'https://api.msgcore.dev',
jwtToken: 'your-jwt-token',
defaultProject: 'my-project', // optional
});import { MsgCoreError, AuthenticationError, RateLimitError } from '@msgcore/sdk';
try {
await msc.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