Options reference
Every option of search, contents and createClient in searchSDK, with types, defaults and limits from the SDK source.
Every call option and client setting, read from the SDK's types and the shared policy. Unknown option names fail as invalid_request; an option a provider cannot honour fails as unsupported before anything is sent.
search(query, options)
query is trimmed of blank characters and must keep 1 to 2000 code points, with no control, bidirectional-control or tag characters.
| Name | Type | Meaning |
|---|---|---|
maxResults? | number | Results wanted: 1 to 100, default 10. More than a provider's limit is unsupported there; a provider without a count parameter is trimmed by searchSDK. |
includeDomains? | readonly string[] | Only results from these hosts. Lowercased and de-duplicated; must not overlap excludeDomains. |
excludeDomains? | readonly string[] | No results from these hosts. |
recency? | Recency | day, week, month or year (day = 1 day, week = 7 days, month = 30 days, year = 365 days). Not with startDate or endDate. |
startDate? | string | Inclusive YYYY-MM-DD, by publication date. |
endDate? | string | Inclusive YYYY-MM-DD, by publication date; not before startDate. |
country? | string | ISO 3166-1 alpha-2 code; sent upper case. |
language? | string | ISO 639-1 code; sent lower case. |
depth? | Depth | fast, standard or deep, mapped to the provider's own levels; it can change the price tier. |
providerOptions? | SearchProviderOptions | Options one provider understands, keyed by id, validated against its spec before sending. |
Call options
Both search and contents take these.
| Name | Type | Meaning |
|---|---|---|
provider? | ProviderId | Provider id. Required unless the client sets provider. |
fallback? | readonly ProviderId[] | Providers tried next, in order, after a fallback-eligible failure. Overrides the client's list. A provider is tried once. |
timeoutMs? | number | Deadline for the whole call, retries and fallback included: 1 to 300000 ms, default 30000. |
attemptTimeoutMs? | number | Deadline for each attempt: 1 to 300000 ms, default timeoutMs. An attempt that passes it fails as attempt_timeout. |
maxRetries? | number | Retries of a transient failure on the same provider: 0 to 5, default 0. |
maxResponseBytes? | number | Largest response body read: 1 KiB to 100 MiB; default 10 MiB for search, 50 MiB for contents. |
signal? | AbortSignal | An AbortSignal; aborting fails the call as aborted. |
contents(urls, options)
urls is one URL or a list of 1 to 100, each at most 2048 characters, http or https. Each provider takes fewer per call; see Provider support.
| Name | Type | Meaning |
|---|---|---|
providerOptions? | ContentsProviderOptions | Options one provider understands, keyed by id, validated against its spec before sending. |
createClient(config)
A client checks its settings when it is created. Call options override client settings.
| Name | Type | Meaning |
|---|---|---|
provider? | ProviderId | Default provider for calls that name none. |
fallback? | readonly ProviderId[] | Default fallback chain. |
keys? | Partial<Record<ProviderId, string>> | API keys by provider id. A missing key is read from the provider's documented variables. |
env? | Readonly<Record<string, string | undefined>> | Variables to read keys from instead of process.env, such as Worker bindings. |
timeoutMs? | number | Default call deadline (see call options). |
attemptTimeoutMs? | number | Default attempt deadline. |
maxRetries? | number | Default retries. |
maxResponseBytes? | number | Default response size limit. |
fetch? | typeof globalThis.fetch | The fetch to use. Tests inject one; the default is the platform's. |
clock? | Clock | Time source (now, setTimeout, clearTimeout); tests inject a virtual clock. |
random? | () => number | Uniform source in [0, 1) for retry jitter. Backoff starts at 250 ms and is capped at 5000 ms; a Retry-After over 60000 ms is not waited for. |
diagnostics? | (event: AttemptDiagnostics<ProviderId>) => void | Opt-in hook called once per sent attempt with the redacted request, status, headers, bounded body and how the spec's paths resolved. Keys never appear; what it throws is ignored. |
registry? | Readonly<Record<ProviderId, unknown>> | Provider specs to use instead of the built-in registry, keyed by id. Validated and copied; their keys become the accepted ids. |