Skip to content

export Class

Rest ​

Constructor ​

ts
 new Rest( options )
ParameterTypeDescription
options = {}RestOptions

Properties ​

get ready : boolean ​

base : string ​

default: 'https://api.telegram.org'

files : string ​

default: 'https://api.telegram.org/file'

onReject? : Function ​

timeout : number ​

default: 10_000

Methods ​

asyncfetchFile( file_id, file ) ​

ParameterTypeDescription
file_idstringThe id of the file to fetch.
file = truebooleanWether to return the class File or an object.

Returns: Promise<false | File>

generate( route, file ) ​

ParameterTypeDescription
routestring
file?boolean

Returns: string

asyncget( route, params, options ) ​

ParameterTypeDescription
routeRoutes
params?any
options?RestRequestOptions

Returns: Promise<any>

asyncpost( route, params, options ) ​

ParameterTypeDescription
routeRoutes
params?any
options?RestRequestOptions

Returns: Promise<any>

asyncrequest( route, params, options ) ​

ParameterTypeDescription
routestring
params = {}any
options = {}RestRequestOptions

Returns: Promise<any>

serialize( object, form ) ​

ParameterTypeDescription
objectany
form?FormDataBuilder

Returns: [any, undefined | FormDataBuilder]

setToken( token ) ​

ParameterTypeDescription
tokenstring

Returns: Rest

A modern, powerful library for building your Telegram bots, with seamless support for both JavaScript and Typescript.