> ## 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.

# Search

> Search across all resource types in a project with the SDK.

The `search()` method lives on the `Royaltyport` client directly (not on a resource accessor). It searches across recordings, compositions, contracts, entities, artists, and writers in a single request.

## search()

### Signature

```js theme={null}
royaltyport.search(projectId, query)
```

### Parameters

| Parameter   | Type     | Required | Description                  |
| ----------- | -------- | -------- | ---------------------------- |
| `projectId` | `string` | Yes      | The project to search within |
| `query`     | `string` | Yes      | The search term              |

### Example

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

const royaltyport = new Royaltyport({
  apiKey: 'rp_your_token_here',
});

const { data: results } = await royaltyport.search('project-id', 'Sony');

console.log(`Found ${results.entities.length} entities`);
console.log(`Found ${results.artists.length} artists`);
console.log(`Found ${results.contracts.length} contracts`);

for (const match of results.entities) {
  console.log(`${match.name} (rank: ${match.rank})`);
  console.log('  Matched keywords:', match.matched_keywords.join(', '));
  console.log('  Metadata match:', match.is_metadata_match);
}
```

***

## Response

The result contains arrays of matches grouped by resource type: `recordings`, `compositions`, `contracts`, `entities`, `artists`, and `writers`.

Each match includes:

| Field               | Type       | Description                             |
| ------------------- | ---------- | --------------------------------------- |
| `id`                | `number`   | The resource ID                         |
| `name`              | `string`   | The resource name                       |
| `matched_keywords`  | `string[]` | Keywords from the query that matched    |
| `is_metadata_match` | `boolean`  | Whether the match was found in metadata |
| `rank`              | `number`   | Relevance ranking score                 |
