> For the complete documentation index, see [llms.txt](https://docs.horizon.ipaper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.horizon.ipaper.io/horizon-api/methods-and-events/content.md).

# Content

### `getContent`

Get a specific piece of content by providing an content `guid`.  Return an `ILeafletContent`

```javascript
const content = api.content.getContent(contentGuid);
console.log('Content', content);
```

`ILeafletContent`

| Property    | Type                                                         | Description                                 |
| ----------- | ------------------------------------------------------------ | ------------------------------------------- |
| $type       | `'offer'` \| `'text'` \| `'image'` \| `'video'` \| `'scene'` | content type                                |
| contentGuid | `string`                                                     | guid of content                             |
| \[key]      | `[type]`                                                     | additional properties based on content type |

Currently, only the `offer` content type has additional properties:

`ILeafletOffer`

| Property     | Type                | Description          |
| ------------ | ------------------- | -------------------- |
| header       | `string`            | header of offer      |
| summary      | `string`            | summary of offer     |
| sales\_price | `{ value: number }` | sales price of offer |
| products     | `ILeafletProduct[]` | products on offer    |

`ILeafletProduct`

| Property    | Type                | Description           |
| ----------- | ------------------- | --------------------- |
| $type       | `'product'`         | content type          |
| sku         | `string`            | sku of product        |
| title       | `string`            | title of product      |
| url         | `string`            | url of product        |
| price       | `{ value: number }` | price of product      |
| sale\_price | `{ value: number }` | sale price of product |
| brand       | `string`            | product brand         |

### `getContentList`

Get all content in the experience. Returns an array of `ILeafletContent`.

```javascript
const contentList = api.content.getContentList();
console.log('Content List', contentList);
```

`ILeafletContent`

| Property    | Type                                                         | Description                                                                                               |
| ----------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| $type       | `'offer'` \| `'text'` \| `'image'` \| `'video'` \| `'scene'` | content type                                                                                              |
| contentGuid | `string`                                                     | guid of content                                                                                           |
| \[key]      | `[type]`                                                     | additional properties based on content type -  see definitions under `getContent` at the top of this page |

### `goToContent`

Scroll to a specific content element by providing a content `guid`.

```javascript
api.content.goToContent(contentGuid);
```

### `getContentElement (deprecated)`

{% hint style="warning" %}
This command is deprecated and will be removed from the API in the near future
{% endhint %}

### `getContentInView`

Get all content currently in view. Returns an array of  `ILeafletContent`.

```javascript
const inView = api.content.getContentInView();
console.log('In view', inView);
```

`ILeafletContent`

| Property    | Type                                                         | Description                                                                                               |
| ----------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| $type       | `'offer'` \| `'text'` \| `'image'` \| `'video'` \| `'scene'` | content type                                                                                              |
| contentGuid | `string`                                                     | guid of content                                                                                           |
| \[key]      | `[type]`                                                     | additional properties based on content type -  see definitions under `getContent` at the top of this page |

***

## Subscription events

The following events can be subscribed to in order to execute code when they occur. The code that should be executed is passed as a callback function when subscribing. You can set up multiple subscriptions to the same event.

These can be very useful fx. for tracking with Google Analytics, etc.

### `subscribe`

Subscribe to content entering the viewport.

```javascript
api.content.subscribe((contentEvent) => {
    // your code
});
```

`contentEvent`

|        |                                                   |                                        |
| ------ | ------------------------------------------------- | -------------------------------------- |
| action | `'viewEnter'` \| `'viewLeave'` \| `'click'`       | name of the event action that occurred |
| source | `'content'` \| `'price'` \| `'splash'` \| `'cta'` | source of the event                    |
| value  | `ILeafletContent`                                 | the content the event occurred for     |

`ILeafletContent`

| Property    | Type                                                         | Description                                                                                               |
| ----------- | ------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| $type       | `'offer'` \| `'text'` \| `'image'` \| `'video'` \| `'scene'` | content type                                                                                              |
| contentGuid | `string`                                                     | guid of content                                                                                           |
| \[key]      | `[type]`                                                     | additional properties based on content type -  see definitions under `getContent` at the top of this page |

### `unsubscribe`

In addition, when you set up a subscription you will get an `unsubscribe` function returned which can be used to cancel the subscription at any time. For example:

```javascript
let myClickSubscription = api.content.subscribe((contentEvent) => {
    // your code
});

myClickSubscription.unsubscribe();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.horizon.ipaper.io/horizon-api/methods-and-events/content.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
