Skip to content

msgcore/msgcore-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@msgcore/sdk

TypeScript SDK for MsgCore - Universal messaging gateway API.

Auto-generated from backend contracts - Do not edit manually

Installation

npm install @msgcore/sdk

Quick Start

import { 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!' },
});

Features

  • 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

API Reference

Analysis / Entities

List all extracted entities for a project with pagination and sorting

// Usage example
await msc.analysisEntities.list();

Get a specific extracted entity by ID

// Usage example
await msc.analysisEntities.get('id');

Analysis / Models

List available LLM models from OpenRouter for analysis

// Get all supported models
await msc.analysisModels.list();

Analysis / Profiles

Create a new analysis profile (versioned pipeline)

// Create an analysis profile
await msc.analysisProfiles.create(data);

List all analysis profiles for a project

// List all profiles
await msc.analysisProfiles.list();

Analysis / Runs

Execute an analysis run with a profile

// Run analysis on specific chats
await msc.analysisRuns.create(data);

Get analysis run statistics for a project

// Get run statistics
await msc.analysisRuns.stats();

Analysis / Schemas

Create a new entity schema for custom extraction

// Create a sentiment analysis schema
await msc.analysisSchemas.create(data);

List all entity schemas for a project

// List all entity schemas
await msc.analysisSchemas.list();

ApiKeys

Generate a new API key

// Create messaging API key
await msc.apikeys.create(data);

List all API keys for project

// List all API keys
await msc.apikeys.list();

Auth

Create a new user account (first user becomes admin)

// Create first admin user
await msc.auth.signup(data);

Login with email and password

// Login with email and password
await msc.auth.login(data);

Chats

List all chats for a project with filtering and pagination

// Usage example
await msc.chats.list(data);

Get details of a specific chat

// Usage example
await msc.chats.get('chatId');

Identities

Create a new identity with platform aliases

// Create identity with Discord and Telegram aliases
await msc.identities.create(data);

List all identities for a project

// List all identities
await msc.identities.list();

Members

List all members of a project

// List all project members
await msc.members.list();

Add a member to a project

// Add a member with admin role
await msc.members.add(data);

Messages

List messages for a project (sent and received)

// Get all messages (sent + received)
await msc.messages.list(data);

Get message statistics for a project

// Get message statistics
await msc.messages.stats();

Platform Logs

List platform processing logs for a project

// List recent platform logs
await msc.platformLogs.list();

List logs for a specific platform configuration

// List logs for specific platform
await msc.platformLogs.get('platformId');

Platforms

Configure a new platform integration

// Add Discord bot
await msc.platforms.create(data);

List configured platforms for project

// List all platforms
await msc.platforms.list();

Projects

Create a new project

// Create a simple project
await msc.projects.create(data);

List all projects

// List all projects
await msc.projects.list();

Webhooks

Create a new webhook for event notifications

// Create webhook for all message events
await msc.webhooks.create(data);

List all webhooks for a project

// List all webhooks
await msc.webhooks.list();

Authentication

API Key (Recommended)

const msc = new MsgCore({
  apiUrl: 'https://api.msgcore.dev',
  apiKey: 'msc_live_your_api_key_here',
  defaultProject: 'my-project', // optional
});

JWT Token

const msc = new MsgCore({
  apiUrl: 'https://api.msgcore.dev',
  jwtToken: 'your-jwt-token',
  defaultProject: 'my-project', // optional
});

Error Handling

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}`);
  }
}

Links

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors