# Function buildApiParams

- buildApiParams<T extends Record<string, unknown>>(
  params: T,
  mapping: readonly { from: keyof T; to: string }[],
  ): Record<string, string | number | boolean>

  Builds an API parameter object by mapping tool-parameter keys to API parameter keys, including only entries whose source value is a primitive `string`, `number`, or `boolean`.

  Falsy-but-valid primitive values (`''`, `0`, `false`) are preserved so that callers can explicitly send them to the downstream API. All other value types (including `undefined`, `null`, objects, arrays, functions, symbols, etc.) are skipped and not forwarded.

  #### Type Parameters

  - T extends Record<string, unknown>

  #### Parameters

  - params: T

    The validated tool-parameter object (e.g. the output of a Zod parse).

  - mapping: readonly { from: keyof T; to: string }[]

    A read-only array of `{ from, to }` pairs describing how each tool-parameter key maps to the corresponding API query-parameter key.

  #### Returns Record<string, string | number | boolean>

  A new `Record<string, string | number | boolean>` containing only the entries that were present in `params`.

  #### Example

      const apiParams = buildApiParams(params, [
        { from: 'country', to: 'country-of-representation' },
        { from: 'group',   to: 'political-group' },
      ]);
      // If params.country === 'SE' and params.group === undefined:
      // => { 'country-of-representation': 'SE' }

  - Defined in tools/shared/paramBuilder.ts:34