REST
classLow-level transport to the Telegram Bot API. Handles auth, JSON vs. multipart bodies, file uploads (including nested attach:// references), timeouts, and 429 retries.
rest.api is a fully-typed proxy exposing every Bot API method — e.g. rest.api.sendMessage({ chat_id, text }).
Declaration
declare class REST Properties
readonly options: RESTOptions;Methods
constructor(token: string, options?: Partial<RESTOptions>);Constructs a new instance of the REST class
download(filePath: string): Promise<Buffer>;| Parameter | Type |
|---|---|
| filePath | string |
Returns Promise<Buffer>
Download a file previously obtained via getFile. Returns the raw bytes. filePath is the file_path field of a Telegram File object.
request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;| Parameter | Type |
|---|---|
| method | string |
| params? | Record<string, unknown> |
Returns Promise<T>
Call a Bot API method by name with an optional params object.