Open source · MIT · Free · v1.0.0

Adsun SDK: Telegram Mini App & Bot Ads in One Line of Code

Official open-source packages for npm, PyPI and GitHub. Add rewarded, interstitial and task ads to your Telegram Mini App, or sponsored messages to your bot, and earn USDT.

npm i adsun-sdk
pip install adsun

React · Vue · Next.js · TypeScript · Python · aiogram · python-telegram-bot

Install from your favourite package manager

Quick start

Copy, paste, earn

Replace 50001 with the block id from your Adsun publisher panel. Use debug: true while testing — test ads are never billed.

Plain HTML

Any Mini App, no bundler.

index.html
<script src="https://telegram.org/js/telegram-web-app.js"></script>
<script src="https://api.adsun.io/sdk.js"></script>
<script>
  // Reward block (Interstitial: "int-50001")
  const ad = window.Adsun.init({ blockId: "50001" });
  document.querySelector("#watch").onclick = () =>
    ad.show().then(() => giveReward()).catch(console.log);
</script>

<adsun-task data-block-id="task-50003">
  <span slot="reward">+100 coins</span>
</adsun-task>

npm / TypeScript

Vite, Next.js, Svelte, Angular.

main.ts
// npm i adsun-sdk
import { initAdsun } from "adsun-sdk";

const ad = await initAdsun({ blockId: "50001", debug: false });

ad.addEventListener("onStart", () => pauseGame());
ad.show()
  .then((r) => r.done && giveReward())
  .catch((r) => console.log(r.description));

React

Rewarded button and Task card.

Earn.tsx
// npm i adsun-sdk
import { useAdsun, AdsunTask } from "adsun-sdk/react";

export function Earn() {
  const showAd = useAdsun({ blockId: "50001", onReward: () => addCoins(100) });
  return (
    <>
      <button onClick={showAd}>Watch ad · +100</button>
      <AdsunTask blockId="task-50003" reward="+100" onReward={() => addCoins(100)} />
    </>
  );
}

Vue 3

Composable for any component.

Earn.vue
<script setup>
// npm i adsun-sdk
import { useAdsun } from "adsun-sdk/vue";
const showAd = useAdsun({ blockId: "50001", onReward: () => coins.value += 100 });
</script>

<template>
  <button @click="showAd">Watch ad · +100</button>
</template>

Python bot (aiogram)

Sponsored message on /bonus.

bot.py
# pip install "adsun[aiogram]"
from aiogram.filters import Command
from adsun import AsyncAdsunBot
from adsun.integrations.aiogram import send_ad

ads = AsyncAdsunBot(token="YOUR_ACCOUNT_TOKEN", block_id="50001")

@dp.message(Command("bonus"))
async def bonus(message):
    u = message.from_user
    await send_ad(message.bot, message.chat.id, ads, u.id, u.language_code or "en")

Reward URL (server)

Grant coins only after a verified view.

reward.py
# Panel → Reward URL:
# https://your-app.com/adsun/reward?userid=[userId]&block=[blockId]&secret=SECRET
from adsun import parse_reward_callback

@app.get("/adsun/reward")
def reward(request):
    cb = parse_reward_callback(request.query_params, secret=SECRET)
    if cb is None:
        return Response(status_code=403)
    add_coins(cb.user_id)  # idempotent: Adsun retries on 5xx
    return {"ok": True}
Ad formats

Every Telegram ad format, one SDK

Rewarded

Fullscreen video or image the user chooses to watch for an in-app reward.

Block id: 50001

Interstitial

Fullscreen ad between screens, closable after a few seconds.

Block id: int-50001

Task

Native <adsun-task> card: open a channel, bot or app, come back and claim.

Block id: task-50001

Bot message

Sponsored message with buttons sent by your Telegram bot.

Block id: 50001 · Bot

How it works

Live in four steps

  1. 1Create a free publisher account on adsun.io.
  2. 2Add your Mini App or bot and create an ad block.
  3. 3Install adsun-sdk (npm) or adsun (PyPI) and paste the block id.
  4. 4Set your Reward URL, test with debug mode and go live.
terminal
# Telegram Mini App
npm i adsun-sdk

# Telegram bot
pip install adsun

# No build step
<script src="https://api.adsun.io/sdk.js"></script>
Why developers choose it

Built for Telegram developers

Free & MIT licensed

No fees to use the SDK. Read, fork and audit the code on GitHub.

TypeScript types

Full typings for AdController, events and init options.

SSR-safe

Import anywhere; the script loads only in the browser.

Zero-dependency Python

Core uses the standard library; async extras are optional.

Server-verified rewards

Reward URL is called only after Adsun verifies a full view.

AdsGram-compatible API

Same init({ blockId }).show() flow — migrate in minutes.

FAQ

Adsun SDK questions

How do I install the Adsun SDK?

For Telegram Mini Apps run npm i adsun-sdk (or add <script src="https://api.adsun.io/sdk.js">). For Telegram bots run pip install adsun.

Is the Adsun SDK free?

Yes. The packages are open source under the MIT license. You earn money from the ads shown; there is no SDK fee.

Does it work with React, Vue and Next.js?

Yes. Use adsun-sdk/react for the useAdsun hook and AdsunTask component, adsun-sdk/vue for Vue 3. It is SSR-safe, so it works in Next.js and Nuxt.

How do I monetize a Telegram bot with Python?

Install adsun, create AdsunBot(token, block_id) and call get_ad(user_id, language), or use the ready aiogram / python-telegram-bot helper send_ad().

How do I give rewards safely?

Set a Reward URL on your block. Adsun calls it only after a server-verified full view; verify it with parse_reward_callback() and grant the reward there.

Can I migrate from AdsGram?

Yes. The API follows the same init({ blockId }).show() pattern and the same events, so most integrations only change the script and block id.

Start earning from your Telegram traffic

Create a block, install the package and see your first impressions today.

npm i adsun-sdk
pip install adsun

Want to try?

See real Adsun ads live in Telegram.