Skip to main content
All CollectionsAPI & Webhooks
Query the Rewatch API
Query the Rewatch API
Scott Goldman avatar
Written by Scott Goldman
Updated over 9 months ago

The Rewatch API is implemented using GraphQL.

GraphQL is described as “a query language for APIs” and is an alternative approach to REST as a means of structuring and interacting with an API.

To learn about the fundamental concepts of GraphQL APIs, check out the learning resources on the GraphQL website or the free How to GraphQL online tutorial.

Exploring the Rewatch GraphQL API

Before getting started, be sure you have followed the steps to generate an API token and have that token available.

One of the benefits of GraphQL is that it provides reflection endpoints for exploring an API’s type system interactively using client tooling. This article discusses the essentials for getting started with exploring Rewatch’s API.

There are multiple client applications to choose from for exploration. One popular open source tool is GraphiQL, which provides a reference implementation for building browser and IDE tools.

This article will use Insomnia, a general-purpose, multi-OS API explorer with a free offering and support for GraphQL.

To get started:

  1. Follow the Insomnia installation documentation for your operating system.

  2. Review the Insomnia help docs for interacting with GraphQL APIs.

To inspect the Rewatch API and issue queries, you will need to know the GraphQL API endpoint for your channel and have a generated API authentication token.

API endpoints for Rewatch channels look like https://<SUBDOMAIN>.rewatch.com/api/graphql, where <SUBDOMAIN> is the subdomain of the channel.

Entering the GraphQL API endpoint in Insomnia

You will also need to add your API token to an Authorization header, and specify application/json in a Content-Type header.

The Authorization header value should take the form of Token token="<API_TOKEN>", where <API_TOKEN> is your Rewatch API token value.

Configuring GraphQL request headers in Insomnia

Once that is complete, you’re ready to start exploring the API.

First, let’s make our first API request by copying and pasting the following query into Insomnia and clicking the Send button:

query {
channel {
name
subdomain
collections(first: 1) {
nodes {
id
name
description
videos {
totalCount
}
}
}
}
}
Issuing a GraphQL query

You now have your first Rewatch GraphQL query results!

Next you can use GraphQL’s built-in documentation exploration features to learn more about the objects and queries in the Rewatch API.

Click the schema button in the query window and then choose Show Documentation to open the documentation browser showing the production API schema.

Show the GraphQL API schema

From here you can click to navigate the API object graph of types and fields that you can reference when querying the Rewatch API.

The GraphQL API explorer window

Integrating with the Rewatch GraphQL API

Integrating your application with the Rewatch API involves writing queries for the data you want and mutations for the data you’d like to update.

There is a long list of GraphQL client libraries for a wide variety of programming languages to make issuing those queries and processing the results more straightforward in your application.

Rate limits

There are two limits that apply to API requests:

  • Hourly limits per channel: this limit is 20,000 requests per hour for Enterprise accounts.

  • Burst requests per user: each channel user is limited to 20 burst requests per second.

The lower of the two limits applies at any given time.

The Rewatch API implements the draft RateLimit HTTP header spec for indicating consumption against the limits.

Did this answer your question?