Writing a 0-dependency Telegram SDK with auto-generated types

Published: (December 31, 2025 at 04:03 AM EST)
1 min read
Source: Dev.to

Source: Dev.to

Why I built a zero‑dependency Telegram SDK

Most Telegram Bot SDKs are either too heavy or have inconsistent type definitions. I wanted something lean, fast, and 100 % type‑safe, so I created Surfgram.

Goals and Benefits

  • Zero dependencies – no axios, no node‑fetch, just native Node.js https.
  • Lightweight – tiny bundle size and fast installation.
  • Secure – fewer dependencies mean a smaller attack surface.
  • Always up‑to‑date – a generator scrapes the official Telegram Bot API documentation; rerun it whenever the API changes.
  • Strict safety – strict null checks and proper type guards eliminate undefined errors in API responses.

Example Usage

import { Bot, Message } from 'surfgram';

const bot = new Bot('TOKEN');

bot.onMessage('/start', (message: Message) => {
  message.sendMessage({ text: 'hi there' });
});

bot.startPolling();

Open Source

The project is fully open‑source. I’m looking for feedback on the architecture and type‑generation logic.

GitHub:

If you like the “no‑bloat” approach, a ⭐ would be much appreciated!

Back to Blog

Related posts

Read more »