Neynar Documentation
Group: Cast APIs
Use this when you need: Search for casts.
Usage
import { NeynarAPIClient, Configuration } from "@neynar/nodejs-sdk";
const client = new NeynarAPIClient(
new Configuration({ apiKey: "YOUR_NEYNAR_API_KEY" })
);
const res = await client.searchCasts({
q: "example", // Query string to search for casts. Supported operators: | Operator | Description | | --------- | -------------------------------------------------------------------------------------------------------- | | `+` | Acts as the AND operator. This is the default operator between terms and can usually be omitted. | | `|` | Acts as the OR operator. | | `*` | When used at the end of a term, signifies a prefix query. | | `"` | Wraps several terms into a phrase (for example, `"star wars"`). | | `(`, `)` | Wrap a clause for precedence (for example, `star + (wars | trek)`). | | `~n` | When used after a term (for example, `satr~3`), sets `fuzziness`. When used after a phrase, sets `slop`. | | `-` | Negates the term. | | `before:` | Search for casts before a specific date. (e.g. `before:2025-04-20` or `before:2025-04-20T23:59:59`) | | `after:` | Search for casts after a specific date. (e.g. `after:2025-04-20` or `after:2025-04-20T00:00:00`) |
// xNeynarExperimental: true,
// mode: "value",
// sortType: "value",
// authorFid: 123,
// viewerFid: 123,
// parentUrl: "example",
// channelId: "example",
// limit: 123,
// cursor: "example",
});
console.log(res);
```
## Parameters
| Parameter | Type | Required | Description |
|--------------------------|---------------------------|----------|---------------------------------------------------------------------------------------------------------|
| `q` | `string` | ✅ | Query string to search for casts. Supported operators: |
| `xNeynarExperimental` | `boolean` | ❌ | - |
| `mode` | `SearchCastsModeEnum` | ❌ | - |
| `sortType` | `SearchCastsSortTypeEnum` | ❌ | - |
| `authorFid` | `number` | ❌ | - |
| `viewerFid` | `number` | ❌ | - |
| `parentUrl` | `string` | ❌ | - |
| `channelId` | `string` | ❌ | - |
| `limit` | `number` | ❌ | - |
| `cursor` | `string` | ❌ | - |
## Response
Returns a `RequestArgs` object.
## Error Handling
try {
const res = await client.searchCasts({
q: "example"
});
// use res
} catch (err) {
// Axios/HTTP errors, invalid params, auth issues, etc.
console.error(err);
}
```
Tips
- Provide a viewerFid when supported to respect mutes/blocks and include
viewer_context. - Keep requests scoped (e.g., use
limit) to improve latency. - Cache results where sensible.