---
title: Using Agent APIs
source: https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/api-agent
---

The New Relic Roku agent provides a comprehensive API for monitoring system and video events in Roku applications. The API is organized into logical categories to help you quickly find the methods you need.

## API categories

Browse API methods by category:

| Category                                                                                                                             | Description                                             |
| ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------- |
| [Agent initialization](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/initialization/overview)     | Initialize the agent and control video session tracking |
| [Lifecycle methods](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/lifecycle/overview)             | Track application and scene lifecycle events            |
| [Event tracking](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/events/overview)                   | Send custom, system, and video events                   |
| [HTTP monitoring](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/http-monitoring/overview)         | Monitor network requests and responses                  |
| [Custom attributes](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/custom-attributes/overview)     | Add metadata to events for filtering and analysis       |
| [Logging](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/logging/overview)                         | Send log messages to New Relic                          |
| [Metrics](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/metrics/overview)                         | Track custom quantitative measurements                  |
| [Harvest configuration](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/harvest/overview)           | Control when data is sent to New Relic                  |
| [Configuration](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/configuration/overview)             | Update agent settings at runtime                        |
| [Domain management](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/domain-management/overview)     | Configure domain substitution for URLs                  |
| [User identification](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/user-identification/overview) | Associate events with specific users                    |

## Quick start guide

### 1. Initialize the agent

Start by initializing the New Relic agent in your Roku application:

```brightscript
sub Main(aa as Object)
    screen = CreateObject("roSGScreen")
    m.port = CreateObject("roMessagePort")
    screen.setMessagePort(m.port)
    scene = screen.CreateScene("VideoScene")
    screen.show()

    m.nr = NewRelic("ACCOUNT ID", "API KEY")
```

### 2. Start system logging

Enable system event monitoring:

```brightscript
m.syslog = NewRelicSystemStart(m.port)
```

### 3. Track video sessions

Monitor video playback:

```brightscript
NewRelicVideoStop(m.nr)
```

### 4. Send custom events

Track application events:

```brightscript
nrSendCustomEvent(m.nr, "MyEvent", "MY_ACTION")
attr = {"key0":"val0", "key1":"val1"}
nrSendCustomEvent(m.nr, "MyEvent", "MY_ACTION", attr)
```

### 5. Add custom attributes

Add metadata to your events:

```brightscript
nrSetCustomAttribute(m.nr, "myNum", 123, "CONTENT_START")
nrSetCustomAttribute(m.nr, "myString", "hello")
```

### 6. Set user identifier

Associate events with specific users:

```brightscript
nrSetUserId(m.nr, "TEST_USER")
```
