Trendflow JS — API Reference - v0.2.0
    Preparing search index...

    Interface ClientOptions

    interface ClientOptions {
        fetch?: {
            (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
            (input: string | URL | Request, init?: RequestInit): Promise<Response>;
        };
        headers?: Record<string, string>;
        language?: string;
        maxProxyAttempts?: number;
        onProxyRotate?: (info: { attempt: number; error: unknown }) => void;
        proxies?: string[];
        retries?: number;
        rpcIds?: RpcIds;
        timeout?: number;
    }
    Index
    fetch?: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    }

    Injectable fetch, for proxies, logging, or tests. Defaults to the global.

    Type Declaration

      • (input: URL | RequestInfo, init?: RequestInit): Promise<Response>
      • Parameters

        • input: URL | RequestInfo
        • Optionalinit: RequestInit

        Returns Promise<Response>

      • (input: string | URL | Request, init?: RequestInit): Promise<Response>
      • Parameters

        • input: string | URL | Request
        • Optionalinit: RequestInit

        Returns Promise<Response>

    headers?: Record<string, string>

    Extra request headers, merged over the browser-like defaults. Chiefly useful for varying user-agent: Google answers the widgetdata endpoints with 429 when the agent string looks like a Node HTTP client, and a server running several sessions wants them to differ.

    language?: string

    Language tag; a bare code such as "en" is expanded to "en-US".

    maxProxyAttempts?: number

    How many proxies to try before giving up on a query. Defaults to the pool size, capped at 5.

    onProxyRotate?: (info: { attempt: number; error: unknown }) => void

    Called when a query fails and the pool rotates. Useful for logging.

    proxies?: string[]

    Proxy URLs to rotate through, e.g. ["http://user:pass@gate.example.com:7000"]. One proxy is pinned per query and the pool advances only when a query fails, because Google binds its cookie and widget token to the exit IP. Requires the optional peer dependency undici. Mutually exclusive with fetch.

    retries?: number

    Retry count for network-level failures within a single request. Default 0.

    rpcIds?: RpcIds

    Override the pinned batchexecute RPC identifiers. They are stable for long stretches but Google does rename them; this lets you patch without waiting for a release.

    timeout?: number

    Per-request timeout in milliseconds. Default 10000.