A CLI tool for creating, publishing, editing, backing up, deleting, and managing Telegra.ph articles using Markdown or HTML.
Telegra.ph lacks a local file editor and account backup tools. This CLI turns Telegra.ph into a local static-site publishing workflow:
- Draft articles locally in Markdown with YAML frontmatter headers and automatic date update banners.
- Embed local image files directly; the CLI auto-hosts them on free mirrors (
Uguu,Sxcu,Catbox) and compiles captions into centered footers. - Edit, update, or delete live articles by title, slug, or URL without losing local source files.
- Fail over to
graph.orgendpoints automatically to bypass regional ISP network blockades without a VPN. - Download all account publications into local
.mdfiles and monitor live view statistics. - Authenticate securely using Telegra.ph API tokens (
tph_token) without linking Telegram account credentials.
git clone https://github.com/spike0en/telegraph-cli.git
cd telegraph-cli
pip install -r requirements.txtCopy .env.example to .env and set your token:
cp .env.example .envRun commands directly with Python or use the provided wrapper scripts:
- Universal Python:
python telegraph.py <command> - Windows (CMD / PowerShell):
.\telegraph <command> - Linux / macOS (Shell):
./telegraph <command> - Editable Install:
pip install -e .thentelegraph <command>
Managing articles takes four basic steps.
Generate a Markdown template in articles/:
python telegraph.py create "My New Guide"This creates articles/My_New_Guide.md with pre-filled frontmatter metadata.
Open articles/My_New_Guide.md in your text editor:
- Write content using standard Markdown syntax (
##section headers,-bullet lists,>callouts). - Embed local images using standard path formats for your operating system:
- Relative Path (Universal):
 - Windows Path (CMD / PowerShell):
 - Linux / macOS Path (Bash / Zsh):

- Relative Path (Universal):
Publish your draft:
python telegraph.py publish "My New Guide"When published:
- Local images upload automatically to free image mirrors (
Uguu,Sxcu,Catbox). - Local image paths in your
.mdfile update to hosted web URLs. - Frontmatter
updated_atand the> Last Updateddate banner refresh automatically. - Live article URLs (
https://telegra.ph/...andhttps://graph.org/...) output to the terminal and save to your.mdfrontmatter header.
Make edits to your local .md file and push the updates live:
python telegraph.py edit "My-New-Guide-07-26"You can pass the article slug, live URL, or filename. The CLI matches the corresponding local .md file automatically.
| Task | CLI Command |
|---|---|
| Draft New Article | python telegraph.py create "Article Title" |
| Publish Local Article | python telegraph.py publish "Article Title" [--hoster uguu/sxcu/catbox] [--no-date] |
| Edit Live Article | python telegraph.py edit <SLUG_OR_URL> [--hoster uguu/sxcu/catbox] [--no-date] |
| Delete Article Live | python telegraph.py delete <SLUG_OR_URL> |
| Download Single Page | python telegraph.py pull <SLUG_OR_URL> |
| Backup All Articles | python telegraph.py pull-all [--clean] |
| Check Page View Count | python telegraph.py views <SLUG_OR_URL> |
| List Account Articles | python telegraph.py list |
| Show Account Info | python telegraph.py account |
| Upload Local Image | python telegraph.py upload <IMAGE_PATH> [--hoster uguu/sxcu/catbox] |
| Create New Account Token | python telegraph.py create-account --short-name "MyBlog" |
Note:
publishandeditupdate the> Last Updated: Month DD, YYYYdate banner and auto-select image mirrors by default. Pass--hoster <uguu|sxcu|catbox|imgbb|imgur>to choose a provider, or--no-dateto leave date banners unchanged.
Telegra.ph compiles Markdown into HTML DOM nodes.
| Markdown Syntax | DOM Element | Rendered Style | Usage |
|---|---|---|---|
## Section or ### Section |
<H3> |
Large Header | Main section titles |
#### Subsection |
<H4> |
Small Header | Subheadings and callouts |
# Title |
Stripped | N/A | Do not use in body text |
Note: Avoid
#headers in the article body. Telegra.ph renders the main title from frontmatter metadata.
- Standard Lists: Place bullet items on consecutive lines without empty spaces:
- Item 1 description.
- Item 2 description.- Paragraph Spacing: Leave a blank line before starting a bullet list.
- Callout Blockquotes: Use
>for callouts. Telegra.ph styles blockquotes with a left margin accent bar.
- Telegram Previews: Use
https://t.me/s/channel/12format for Telegram links to generate instant web previews. - Image Failover Chain: Local image references (
.png,.jpg,.jpeg,.gif,.webp,.mp4) automatically upload through mirror providers (Uguu.se->Sxcu.net->Catbox.moe->ImgBB->Imgur). - Manual Uploads: Run
python telegraph.py upload path/to/image.png [--hoster uguu/sxcu/catbox]to upload a file directly. - Image Footers & Captions: Alt text in Markdown (
) or HTML<figure><figcaption>tags render as centered image footers.
Local files in articles/ track metadata using YAML frontmatter:
---
title: "Article Title Here"
path: "Article-Title-Here-07-26"
url: "https://telegra.ph/Article-Title-Here-07-26"
mirror_url: "https://graph.org/Article-Title-Here-07-26"
author: "Author Name"
author_url: "https://example.com"
views: 120
updated_at: "2026-07-26"
---Create an account token directly from the CLI without a Telegram phone number or bot:
python telegraph.py create-account --short-name "MyBlog" --author "Your Name"This saves TELEGRAPH_ACCESS_TOKEN to your .env file and outputs a management auth URL.
Link an account managed by the @Telegraph Telegram bot:
- Open
@Telegraphin Telegram and click Log in on this device. - Copy the authentication link (
https://edit.telegra.ph/auth/...) without opening it in a browser. - Run the auth helper:
python -m telegraph_api.auth "https://edit.telegra.ph/auth/YOUR_LINK"- Open
@Telegraphin Telegram and click Log in on this device. - Open the link in a browser.
- Press F12 -> Application/Storage -> Cookies ->
https://edit.telegra.ph. - Copy
tph_tokenand paste it into.env:
TELEGRAPH_ACCESS_TOKEN=your_telegraph_access_token_heretelegraph-cli/
├── telegraph_api/ # Core package
│ ├── __init__.py # Package init
│ ├── manager.py # API client and AST engine
│ ├── cli.py # CLI commands and argument parser
│ └── auth.py # Token extractor helper
├── articles/ # Local article Markdown storage
├── .env.example # Environment template
├── .gitignore # Git ignore file
├── pyproject.toml # Package manifest
├── requirements.txt # Dependencies
├── LICENSE # MIT License
├── telegraph.py # Cross-platform entrypoint
├── telegraph # Shell script wrapper
├── telegraph.bat # Windows Batch launcher
└── telegraph.ps1 # Windows PowerShell launcher
Distributed under the MIT License. Copyright (c) 2026 spike0en.