> For the complete documentation index, see [llms.txt](https://docs.discover.r1learning.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.discover.r1learning.com/api-guide-video-data.md).

# API Guide: Video Data

## Introduction

This guide provides detailed instructions for integration partners on how to access data related to users watching videos via Version 2 of the R1 Discover API. By following this guide, partners can efficiently integrate with the API to retrieve a comprehensive view of user video interactions within the R1 Discover platform, including company-wide and user-specific video metrics.

***

## Prerequisites

Before starting the integration process, ensure the following:

* You have an active R1 Discover Tech Partner account.
* You can generate a Bearer token for authentication.

Detailed instructions for setting up your account and generating a token are available here: R1 API: Getting Started (#).

***

## Workflow Overview

Understanding the sequence of API calls is essential for effectively retrieving user video data. This section outlines the recommended workflow for accessing the relevant endpoints in Version 2 of the R1 Discover API.

Workflow Diagram:

1. [Generate Bearer Token](#id-1.-generate-bearer-token)
2. [Retrieve Core Company Data](#id-2.-retrieve-company-list)
   * [Company List](#id-2.-retrieve-company-list)
   * [Company User List](#id-3.-retrieve-company-user-list)
   * [Company Topic List](#id-4.-retrieve-company-topic-list)
   * [Company Activity List](#id-5.-retrieve-company-activity-list)
3. Access Video Data
   * [View Company Video Metrics](#id-6.-view-company-video-metrics)
   * [View User Video Metrics](#id-7.-view-user-video-metrics)

***

## Step-by-Step Instructions

### 1. Generate Bearer Token

Instructions:

* Log in to your R1 Discover Tech Partner account.
* Navigate to the "My Companies" tab.
* Click the "Key" icon to generate a Bearer token.
* Copy the token to a secure location. Note: The token will not be visible after you leave the page.

Link to Documentation: [Generate Bearer Token](/introduction/r1-api-getting-started.md)

***

### 2. Retrieve Company List

Instructions:

* Use the "List Companies" endpoint to retrieve a paginated list of companies and their IDs.
* Make a GET request to <https://api.r1learning.com/api/v2/companies?page={page}\\&limit={limit}>.
* Include the Bearer token in the Authorization header.

Example Request:

```
GET https://api.r1learning.com/api/v2/companies?page=1&limit=50
Headers:
  Content-Type: application/json
  Accept: application/json
  Authorization: Bearer {token}
```

Link to Documentation: [List Companies](/endpoint-descriptions/company-management/list-companies.md)

***

### 3. Retrieve Company User List

Instructions:

* Use the "List Company Users" endpoint to retrieve a list of users associated with a specific company.
* Make a GET request to <https://api.r1learning.com/api/v2/users/{companyId}?page={page}\\&limit={limit}>.
* Replace {companyId} with the company ID from the previous step.
* Include the Bearer token in the Authorization header.

Example Request:

```
GET https://api.r1learning.com/api/v2/users/12345?page=1&limit=50
Headers:
  Content-Type: application/json
  Accept: application/json
  Authorization: Bearer {token}
```

Link to Documentation: [List Company Users](/user-management/list-company-users.md)

***

### 4. Retrieve Company Topic List

Instructions:

* Use the "List Company Topics" endpoint to retrieve all topics available to a company.
* Make a GET request to <https://api.r1learning.com/api/v2/companies/topics?companyId={companyId}\\&page={page}\\&limit={limit}>.
* Replace {companyId} with the desired company ID (use 0 to retrieve topics for all companies).
* Include the Bearer token in the Authorization header.

Example Request:

```
GET https://api.r1learning.com/api/v2/companies/topics?companyId=12345&page=1&limit=50
Headers:
  Content-Type: application/json
  Accept: application/json
  Authorization: Bearer {token}
```

Link to Documentation: [List Company Topics](/endpoint-descriptions/company-management/list-company-topics.md)

***

### 5. Retrieve Company Activity List

Instructions:

* Use the "List Company Activities" endpoint to retrieve all activities available to a company, including video-related activities.
* Make a GET request to <https://api.r1learning.com/api/v2/companies/activities?companyId={companyId}\\&page={page}\\&limit={limit}>.
* Replace {companyId} with the desired company ID (use 0 to retrieve activities for all companies).
* Include the Bearer token in the Authorization header.

Example Request:

```
GET https://api.r1learning.com/api/v2/companies/activities?companyId=12345&page=1&limit=50
Headers:
  Content-Type: application/json
  Accept: application/json
  Authorization: Bearer {token}
```

Link to Documentation: [List Company Activities](/endpoint-descriptions/company-management/list-company-activities.md)

***

### 6. View Company Video Metrics

Instructions:

* Use the "List Company Video Metrics" endpoint to retrieve a paginated list of video sessions for all users within a company.
* Make a GET request to <https://api.r1learning.com/api/v2/metrics/metrics/videos/companies/{companyId}?page={page}\\&limit={limit}>.
* Replace {companyId} with the desired company ID.
* Include the Bearer token in the Authorization header.

Example Request:

```
GET https://api.r1learning.com/api/v2/metrics/metrics/videos/companies/12345?page=1&limit=50
Headers:
  Content-Type: application/json
  Accept: application/json
  Authorization: Bearer {token}
```

Link to Documentation: [List Company Video Metrics](/metrics-and-analytics/list-company-video-metrics.md)&#x20;

***

### 7. View User Video Metrics

Instructions:

* Use the "List User Video Metrics" endpoint to retrieve a paginated list of video sessions for a specific user.
* Make a GET request to <https://api.r1learning.com/api/v2/metrics/metrics/videos/users/{userId}?page={page}\\&limit={limit}>.
* Replace {userId} with the user ID obtained from the "List Company Users" endpoint.
* Include the Bearer token in the Authorization header.

Example Request:

```
GET https://api.r1learning.com/api/v2/metrics/metrics/videos/users/17434?page=1&limit=50
Headers:
  Content-Type: application/json
  Accept: application/json
  Authorization: Bearer {token}
```

Link to Documentation: [List User Video Metrics](/metrics-and-analytics/list-user-video-metrics.md)

***

## Notes

* Authentication: All requests require a valid Bearer token in the Authorization header to avoid 401 Unauthenticated errors.
* Pagination: Use the page and limit query parameters to manage large datasets efficiently (default: 50, max: 100).
* Error Handling: Be prepared to handle common errors such as 401 (Unauthenticated) and 403 (Unauthorized). Refer to individual endpoint documentation for details.
* Contextual Data: Use the "List Company Topics" and "List Company Activities" endpoints to correlate video metrics with specific topics or activities that include videos.

For additional resources, explore the [R1 Discover API Postman Collection](https://www.postman.com/fbomher/r1-discover-api/documentation/tqglan1/r1disover-api-v2) or contact support at <r1team@r1learning.com>.
