> ## Documentation Index
> Fetch the complete documentation index at: https://docs.telemetree.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup Telemetree Ads

> Everything you need to know about setting up Telemetree Ads SDK and monetizing your games

# Telemetree Ads API

<CardGroup cols={2}>
  <Card title="Closed access" icon="users-gear">
    Telemetree Ads is currently in closed access. If you are interested in joining, please, follow the instructions!
  </Card>

  <Card title="Getting access" icon="user-plus">
    Sign up and [our website](https://telemetree.io/) and reach out to our [manager](https://t.me/telemetree_eden) to finish your KYC process and get your API key.
  </Card>
</CardGroup>

We provide a set of API endpoints to help you monetize your games. You can use these endpoints to fetch tasks, display them, and verify the user's completion of the tasks.
To make things easier, we also provide a React SDK that you can use to integrate our API into your game.

# Telemetree Ads React SDK

<Tip>We've expanded our analytics library to include Telemetree Ads SDK, so if you're already using our analytics library, skip to the next two steps.</Tip>

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @tonsolutions/telemetree-react
  ```

  ```bash yarn theme={null}
  yarn add @tonsolutions/telemetree-react
  ```
</CodeGroup>

## Initialization

<CodeGroup>
  ```jsx theme={null}
  import { TaskManager } from '@tonsolutions/telemetree-react';
  ```
</CodeGroup>

## Fetching tasks

```mermaid theme={null}
flowchart TD
    A[User initiates player session] --> B{Check local storage for tasks}
    B -->|No tasks or expired| C[Fetch tasks from server]
    B -->|Unexpired tasks| D[Show sponsored tasks in your task section]
    C --> D
```

The `TaskManager` component will fetch tasks from the API and store them in the user's local storage for 48 hours. Once the tasks are expired, the component will fetch them again during the next session.

## Displaying tasks

<Warning><b>Important!</b> <br />Incorrect use of this method will lead to lower earning potential for you and your game. Don't lost out on money!</Warning>

```mermaid theme={null}
flowchart TD
    A[Application shows the sponsored task] --> B[Pass 'task_id' and 'telegram_id' to display_task endpoint]
    B --> | Authentic request | C[Increment impressions]
    B --> | Bad actor request | D[Show error message]
```

Use the displaying endpoint only when the user sees the full tasks.

Calling this endpoint will increase the number of impressions for the task.

## Verifying tasks

```mermaid theme={null}
flowchart TD
    A[User presses the 'Verify' button] --> B[Pass 'task_id' and 'telegram_id' to verify_task endpoint]
    B --> | Task completed | C[Increment impressions]
    B --> | Task not completed | D[Show error message]
```

Whenever the user presses the "Verify" button, the `TaskManager` component will call our endpoint to double check if the user has completed the task.

If the task is completed, your balance will be updated to reflect the changes.

Don't forget to reward the user for completing the task!
