Telegra.ph API wrapper with docs and files upload
npm install telegraph-wrapperOfficial docs - https://telegra.ph/api



npm i telegraph-wrapperor
yarn add telegraph-wrapper
const Telegraph from 'telegraph-wrapper'
or
const { createAccount, upload } from 'telegraph-wrapper'
#### Modulesimport * as Telegraph from 'telegraph-wrapper'
or
import { createAccount, upload } from 'telegraph-wrapper'
All methods presented in official docs:
https://telegra.ph/api#Available-methods
Methods returns Promise with api response.
Hover any method and property to preview JSDocs.
Examples:
``
import * as Telegraph from 'telegraph-wrapper';
Telegraph.createAccount({
short_name: 'acc',
})
.then(console.log)
.catch(err => { / ... / });
``
import { getAccountInfo } from 'telegraph-wrapper';
getAccountInfo({
access_token: '...',
})
.then(console.log)
.catch(err => { / ... / });
``
import { createAccount } from 'telegraph-wrapper';
try {
const acc = await createAccount({
short_name: 'acc',
});
} catch (err) {
/ ... /
}
`
(see #Types).⚠️ Do not mix local and remote URLs! ⚠️
`
upload([
'./meme.png',
'./meme2.png',
])or
upload('./meme.png')
`$3
All types also included + upload responses.
Names are the same with official docs.
JSDocs included. You can import any type and see docs by hovering it.
#### Upload types
TelegraphOK - Telegra.ph success responseTelegraphOK[].src - Telegra.ph file link. Example: /file/123abc123abc123abc123.ext
`
type TelegraphOK = Array<{
src: string,
}>;
`TelegraphError - Telegra.ph error responseTelegraphOK.error - Error body
`
type TelegraphError = {
error: string,
};
``