Skip to main content

TypeScript

The package includes TypeScript declarations. Both named and default imports of Emby are supported; no separate types package is needed.

import {
Emby,
type EmbyConfig,
type ParticipantRights,
type RequestControlOptions,
} from '@emby-chat/node-sdk';

const config: EmbyConfig = {
api_token: process.env.EMBY_API_TOKEN,
api_url: 'https://api.getchat.io',
};
const emby = new Emby(config);

const rights: ParticipantRights = { send_messages: false };
await emby.updateParticipantRights('support-42', 'u-2', rights);

Infer generated method types​

Generated input and response types are not exported by name from the package root. Derive them from the corresponding method:

type ChatListInput = Parameters<typeof emby.api.chatList>[0];
type ChatListResponse = Awaited<ReturnType<typeof emby.api.chatList>>;

const input: ChatListInput = {
query: { page: 1, limit: 20, with_owner: '1' },
};
const result: ChatListResponse = await emby.api.chatList(input);

Methods default to the response type for their endpoint. Supplying an explicit response generic overrides that type; it does not validate the server's response. Raw requestApi() calls return unknown by default.

Convenience types and generated types​

Some hand-written types preserve older SDK contracts. For example, ChatType contains private, group and system, while the REST API accepts private, group, supergroup and channel. Use generated methods for supergroups and channels:

await emby.api.chatCreate({
body: {
chat: {
id: 'announcements',
title: 'Announcements',
type: 'channel',
owner: { id: 'u-1', name: 'Alice' },
},
},
});

Hand-written resource interfaces can also omit fields, including message seq and attachments. Prefer inferred generated response types when you need the current endpoint fields. Zod validates outgoing inputs; incoming responses are not runtime-validated.

The API reference is generated from the SDK's public TypeScript entry point. Referenced types explain method inputs and outputs; they are not necessarily named exports you can import from the package root.