> For the complete documentation index, see [llms.txt](https://sdk-doc.tyrads.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sdk-doc.tyrads.com/iframe/installation/golang.md).

# Golang

{% hint style="warning" %}

#### Initialize After Media Source or MMP Initialization

Please initialize our SDK only after the media source or MMP data is initialized. This ensures that the media source data is sent correctly and prevents passing empty values.
{% endhint %}

Integrate your Golang app with us using our Golang package

## Installation

Add `github.com/tyrads-com/tyrads-go-sdk-iframe` to your `app` as follows:

```sh
go get -u github.com/tyrads-com/tyrads-go-sdk-iframe
```

> The latest available version of Golang `github.com/tyrads-com/tyrads-go-sdk-iframe` is [v0.1.6](https://github.com/tyrads-com/tyrads-go-sdk-iframe/releases/tag/v0.1.6).

## Get Started

After successfully installing our package, create a TyrAdsSdk object with your API key and API secret:

```go
tyrAdsSdk = tyrads.NewTyrAdsSdk(
	API_KEY,
	API_SECRET,
	"") // Leave it empty ("") to use default "en" (English)
```

### Localization

This `TyrAdsSdk` class also supports localization, more info about [localization](/iframe/installation/manual-integration.md#localization)

For example:

```go
tyrAdsSdk = tyrads.NewTyrAdsSdk(
    API_KEY,
    API_SECRET,
    "en")
```

## Authentication

You can do the authentication by calling to our package

```go
sign, err := tyrAdsSdk.Authenticate(tyrads.AuthenticationRequest{
    PublisherUserID: PUBLISHER_USER_ID,
})
```

After obtaining the token successfully, you can call `iframeUrl` method to get the iframe URL

```go
iframeUrl, err := tyrAdsSdk.IframeUrl(token, nil)
// Result: https://sdk.tyrads.com?token=eyJ2YWwiOiI3M3NIeUpNQlp4QzA1TlRHVzhxRExhWWNTeUQ5TTJIT0h3NXBvL3djVVp1Z09MR20wOTJJOTRReDBuYUFLeXhmVGRCaGYra2gvVGcydWFlbUh6aWR6S00vTmV0SEtVZVlWNk5Pdkc5Wnd5bytkSkxmUnA0aWt2eE9yQ01YTXF6LzBnRmZ3RUpucHMxem95WnRkYkVlQXJQNER3cDRZVkttb1lBdEIrZlB6cFZ3R25SSEE5UjROa2U2cGJTeTJod2c2UmI3UnN0QzZiN2Y2cENBYTlqaEhvQXhtdjM5UERPU2tDdWpHMmJIQ2N1cVRldVQ4a3hDSEE9PSIsInZlYyI6InNWbzZrejZRa09iS0tDeDUiLCJ0YWciOiJ1eDNnbjEwNEdUWXpvV1J2TTZVck1BPT0ifQ==
```

{% hint style="info" %}

1. A new token must be requested each time a user wants to access the offerwall.
2. Each token is valid for **7 days** only
   {% endhint %}

### Deeplinking Routes

This `iframeUrl` method also supports deeplinking, more info about [deeplinking routes](/iframe/installation/manual-integration.md#deeplinking-routes)

For example:

```go
deeplink := "/settings/language"
iframeUrl, err := tyrAdsSdk.IframeUrl(token, &deeplink)
// Result: https://sdk.tyrads.com?to=/settings/language&token=eyJ2YWwiOiI3M3NIeUpNQlp4QzA1TlRHVzhxRExhWWNTeUQ5TTJIT0h3NXBvL3djVVp1Z09MR20wOTJJOTRReDBuYUFLeXhmVGRCaGYra2gvVGcydWFlbUh6aWR6S00vTmV0SEtVZVlWNk5Pdkc5Wnd5bytkSkxmUnA0aWt2eE9yQ01YTXF6LzBnRmZ3RUpucHMxem95WnRkYkVlQXJQNER3cDRZVkttb1lBdEIrZlB6cFZ3R25SSEE5UjROa2U2cGJTeTJod2c2UmI3UnN0QzZiN2Y2cENBYTlqaEhvQXhtdjM5UERPU2tDdWpHMmJIQ2N1cVRldVQ4a3hDSEE9PSIsInZlYyI6InNWbzZrejZRa09iS0tDeDUiLCJ0YWciOiJ1eDNnbjEwNEdUWXpvV1J2TTZVck1BPT0ifQ==
```

### Embedding The Iframe

If your website is using html, you can add an iframe to your page to integrate TyrAds web:

```html
<iframe id="tyrads_iframe" src="[IFRAME_LINK]" height="650" width="300"></iframe>
```

For example:

```html
<iframe id="tyrads_iframe" src="https://sdk.tyrads.com?token=eyJ2YWwiOiI3M3NIeUpNQlp4QzA1TlRHVzhxRExhWWNTeUQ5TTJIT0h3NXBvL3djVVp1Z09MR20wOTJJOTRReDBuYUFLeXhmVGRCaGYra2gvVGcydWFlbUh6aWR6S00vTmV0SEtVZVlWNk5Pdkc5Wnd5bytkSkxmUnA0aWt2eE9yQ01YTXF6LzBnRmZ3RUpucHMxem95WnRkYkVlQXJQNER3cDRZVkttb1lBdEIrZlB6cFZ3R25SSEE5UjROa2U2cGJTeTJod2c2UmI3UnN0QzZiN2Y2cENBYTlqaEhvQXhtdjM5UERPU2tDdWpHMmJIQ2N1cVRldVQ4a3hDSEE9PSIsInZlYyI6InNWbzZrejZRa09iS0tDeDUiLCJ0YWciOiJ1eDNnbjEwNEdUWXpvV1J2TTZVck1BPT0ifQ==" height="650" width="300"></iframe>
```

## Example

For example implementation using our Golang SDK, you can find it here

{% embed url="<https://github.com/tyrads-com/go-sdk-iframe-example/blob/main/TyrAdsSdk/main.go>" %}
