API Reference

Registration

Before using the advertising features, please complete the registration process.

Creating a Platform

A Platform represents your APP or Website. After creating a Platform, it needs to be reviewed by Ton AI. Only after approval can you become a traffic source for Ton AI.

Fill in the relevant information about your APP.

Creating a Block

A Block represents an ad space. You can create multiple ad spaces to compare the performance of different placements.

Creating a Block only requires you to add a Name.


Ad Integration

We provide two methods for embedding ads. Choose the method that best suits your app type.

Embedding Banners via SDK

To display banner ads in your MiniAPP, first ensure that the ad space has an aspect ratio of 5:1, such as 400x80. Then, import the necessary SDK components:

import { TonAdBanner } from 'ton-ai-sdk';
import 'ton-ai-sdk/dist/index.css';

Next, embed the TonAdBanner component in the appropriate location within your HTML:

Note: BlockID is the ID of the Block created under your Platform in the management console. You can copy it from there.

<div>
  <!-- Embed the SDK's div -->
  <TonAdBanner blockId={BlockID}></TonAdBanner>
</div>

The SDK will fetch ads suitable for the current user and automatically report Click events to Ton AI.

Example:

Example

Embedding Ads via API

We provide two APIs:

  1. Fetch Ads - This API retrieves multiple ads. You need to embed the ad information into your product.
  2. Report Click Event - This API reports the event when a user clicks on an ad.

This allows you to embed ads into any interface of your product.

Example:

Example