> For the complete documentation index, see [llms.txt](https://adfather.gitbook.io/adfather/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://adfather.gitbook.io/adfather/publisher/getting-started.md).

# Getting Started

### Insert script​ <a href="#insert-script" id="insert-script"></a>

To connect your Mini App to the AdFather, place the script `app-client-sdk.js` in the `<head>` tag using this code:

```html
<script src="https://cdn.adfather.xyz/app-client-sdk.js"></script>
```

***

### Initialize AdFather SDK​ <a href="#initialize-a-dsgram-sdk" id="initialize-a-dsgram-sdk"></a>

<pre class="language-javascript" data-full-width="false"><code class="lang-javascript">const AdFatherController = await window.AdFatherSDK.AdFather.init({ 
<strong>    propertyToken: 'your-property-token',
</strong>    isDeepIntegration: false // true - for our partners
<strong>});
</strong></code></pre>

`your-property-token` — to get, [contact us](https://t.me/ChainRoman)

***

*You can skip the description of each method and go straight to the full integration examples.*

{% content-ref url="/pages/sO95TOVlzGYuG6bcavIh" %}
[Code Examples](https://adfather.gitbook.io/adfather/publisher/code-examples.md)
{% endcontent-ref %}

***

**To improve targeting and maximize advertising revenue, we recommend initializing the SDK at the root of your project.**

<pre class="language-jsx"><code class="lang-jsx"> useEffect(() => {
    window.AdFatherSDK.AdFather.init({ 
        propertyToken: 'your-property-token',
        isDeepIntegration: false // true - for our partners
<strong>    })
</strong>  }, []);
</code></pre>

{% hint style="info" %}
You can call `AdFatherSDK.AdFather.init()` as many times as you want; \
you will continue working with the same instance that was initialized during the first call.
{% endhint %}

### Initialize Offer Wall Instance <a href="#initialize-a-dsgram-sdk" id="initialize-a-dsgram-sdk"></a>

Creating an ad unit

<pre class="language-javascript" data-full-width="false"><code class="lang-javascript">const offerWallController = AdFatherController.initOfferWall({
<strong>    adUnitToken: 'your-unit-token' 
</strong><strong>});
</strong></code></pre>

`your-unit-token` — to get, cont

***

### Getting a feed

Getting a list of all available tasks

{% code fullWidth="false" %}

```javascript
const feed = await AdFatherOfferWall.getFeed();
```

{% endcode %}

`feed` - array with task

life work

{% code title="Task type" %}

```typescript
{
    id: string;
    title: string;
    description: string;
    btn_label: string;
    icon: string;
    url?: string;
    url_type?: "TELEGRAM" | "EXTERNAL";
    is_done: boolean;
}
```

{% endcode %}

***

### Click on task function

This function automatically redirects the user to the link for task completion.\
It should be called every time the user clicks on a task

{% code fullWidth="false" %}

```javascript
AdFatherOfferWall.clickTask('example-task-id')
```

{% endcode %}

`example-task-id` — `task.id`, the unique identifier of the task the user clicked on.

***

### Task completion check

This function should be called every time a task needs to be checked for completion by the user

{% code fullWidth="false" %}

```javascript
const checkResult = await AdFatherOfferWall.checkTask('example-task-id');
```

{% endcode %}

`example-task-id` — `task.id`, the unique identifier of the task being checked for user completion.
