> ## Documentation Index
> Fetch the complete documentation index at: https://docs.royaltyport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Access your Royaltyport data programmatically with the official Node.js SDK.

The `@royaltyport/sdk` is the official Node.js client for the Royaltyport API. It provides access to projects, contracts, catalog data, CRM records, statements, and cross-resource search with built-in pagination, error handling, and automatic retries.

The SDK is written in TypeScript and ships with full type definitions — you get autocomplete and type checking out of the box.

## Requirements

* Node.js >= 18.0.0

## Installation

```bash theme={null}
npm install @royaltyport/sdk
```

## Quick Start

<Steps>
  <Step title="Install the SDK">
    ```bash theme={null}
    npm install @royaltyport/sdk
    ```
  </Step>

  <Step title="Create a client">
    ```js theme={null}
    import { Royaltyport } from '@royaltyport/sdk';

    const royaltyport = new Royaltyport({
      apiKey: 'rp_your_token_here',
    });
    ```
  </Step>

  <Step title="Make your first request">
    ```js theme={null}
    const { data: projects } = await royaltyport.projects.list();

    for (const project of projects) {
      console.log(project.name);
    }
    ```
  </Step>
</Steps>

***

## Configuration

The `Royaltyport` constructor accepts a configuration object:

```js theme={null}
import { Royaltyport } from '@royaltyport/sdk';

const royaltyport = new Royaltyport({
  apiKey: 'rp_your_token_here',
  baseUrl: 'https://api.royaltyport.com', // optional
});
```

| Parameter | Type       | Required | Default                       | Description                                         |
| --------- | ---------- | -------- | ----------------------------- | --------------------------------------------------- |
| `apiKey`  | `string`   | Yes      | —                             | API token (`rp_` prefix) or OAuth access token      |
| `baseUrl` | `string`   | No       | `https://api.royaltyport.com` | Custom API base URL                                 |
| `fetch`   | `function` | No       | `globalThis.fetch`            | Custom fetch implementation for testing or proxying |

***

## Response Format

All methods return a response object containing the data and rate limit information:

```js theme={null}
const response = await royaltyport.projects.list();

console.log(response.data);      // the requested data
console.log(response.rateLimit);  // { limit: 100, remaining: 99, reset: 1711929600 }
```

| Field                 | Description                                  |
| --------------------- | -------------------------------------------- |
| `data`                | The response payload (type varies by method) |
| `rateLimit.limit`     | Maximum requests allowed per window          |
| `rateLimit.remaining` | Requests remaining in the current window     |
| `rateLimit.reset`     | Unix timestamp when the window resets        |

***

## Automatic Retries

The SDK automatically retries requests that fail with `429` (rate limit) or `5xx` (server error) status codes, up to 3 times with exponential backoff. No configuration is needed.

***

## Available Resources

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/sdk-reference/authentication">
    API tokens, OAuth tokens, and environment variables.
  </Card>

  <Card title="Error Handling" icon="triangle-alert" href="/sdk-reference/error-handling">
    Error classes, retry behavior, and status codes.
  </Card>

  <Card title="Pagination" icon="list" href="/sdk-reference/pagination">
    Paginated results and iteration patterns.
  </Card>

  <Card title="Projects" icon="folder" href="/sdk-reference/projects">
    List and retrieve projects.
  </Card>

  <Card title="Artists" icon="mic" href="/sdk-reference/artists">
    List and retrieve artists.
  </Card>

  <Card title="Writers" icon="pen-line" href="/sdk-reference/writers">
    List and retrieve writers.
  </Card>

  <Card title="Recordings" icon="disc-3" href="/sdk-reference/recordings">
    List and retrieve recordings.
  </Card>

  <Card title="Compositions" icon="music" href="/sdk-reference/compositions">
    List and retrieve compositions.
  </Card>

  <Card title="Entities" icon="building" href="/sdk-reference/entities">
    List and retrieve entities.
  </Card>

  <Card title="Relations" icon="users" href="/sdk-reference/relations">
    List and retrieve relations.
  </Card>

  <Card title="Contracts" icon="file-text" href="/sdk-reference/contracts">
    List, retrieve, upload, download, and track contracts.
  </Card>

  <Card title="Statements" icon="file-spreadsheet" href="/sdk-reference/statements">
    List, retrieve, upload, download, and track statements.
  </Card>

  <Card title="Search" icon="search" href="/sdk-reference/search">
    Search across all resource types in a project.
  </Card>
</CardGroup>
