# Golang

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](/v3.0/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](/v3.0/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>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sdk-doc.tyrads.com/v3.0/iframe/installation/golang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
