Socket
Socket
Sign inDemoInstall

telegraph-wrapper

Package Overview
Dependencies
13
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    telegraph-wrapper

Telegra.ph API wrapper with docs and files upload


Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Help

Rate me

telegraph-wrapper

Telegra.ph API wrapper

Official docs - https://telegra.ph/api

Features

  • files upload (local and remote by url)
  • all types included
  • full docs included
  • proxy for upload (TODO)

Install

npm i telegraph-wrapper

or

yarn add telegraph-wrapper

Usage

Import

CommonJS

const Telegraph from 'telegraph-wrapper'

or

const { createAccount, upload } from 'telegraph-wrapper'

Modules

import * as Telegraph from 'telegraph-wrapper'

or

import { createAccount, upload } from 'telegraph-wrapper'

Methods

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) {
  /* ... */
}

Upload

Allows upload local files and remote (by url) to telegra.ph servers. Returns Promise<TelegraphOK | TelegraphError> (see #Types).

⚠️ Do not mix local and remote URLs! ⚠️

upload([
  './meme.png',
  './meme2.png',
])

or 

upload('./meme.png')

Types

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 response

TelegraphOK[].src - Telegra.ph file link. Example: /file/123abc123abc123abc123.ext

type TelegraphOK = Array<{
  src: string,
}>;

TelegraphError - Telegra.ph error response

TelegraphOK.error - Error body

type TelegraphError = {
  error: string,
};

Keywords

FAQs

Last updated on 09 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc