Skip to content

Latest commit

 

History

History
89 lines (52 loc) · 1.91 KB

readme.md

File metadata and controls

89 lines (52 loc) · 1.91 KB

📝 telegra.ph

NPM Version Build Status

Tiny API helper for Telegra.ph.

Telegra.ph API docs

API

Installation

$ npm install telegra.ph --save

Example

Create an account

import Telegraph from "telegra.ph"

const client = new Telegraph()

const account = client.createAccount()
client.token = account.access_token

const pages = await client.getPageList()
console.log(pages)

Use existing account

import Telegraph from "telegra.ph"

const client = new Telegraph(process.env.TOKEN)

const pages = await client.getPageList()
console.log(pages)

Use arbitrary HTTP Client

import Telegraph from "telegra.ph"
import { Fetch } from "telegra.ph/clients"

const client = new Telegraph(process.env.TOKEN, { client: Fetch })

const pages = await client.getPageList()
console.log(pages)

API documentation

.createAccount(shortName, name, url)

.createPage(title, content, authorName, authorUrl, returnContent)

.editAccountInfo(shortName, name, url)

.editPage(path, title, content, authorName, authorUrl, returnContent)

.getPage(path, returnContent)

.getViews(path, year, month, day, hour)

.getPageList(path, offset, limit)

.revokeAccessToken()