@minipim/sdk is the official TypeScript client. It wraps openapi-fetch with types generated from the API spec, so every path, parameter and response is typed. It ships ESM and CommonJS builds, and the root entry has no Node-only imports, so it runs in Edge runtimes too.

With the API

npm install @minipim/sdk
import { createMinipimClient, getAttribute } from '@minipim/sdk';

const pim = createMinipimClient({
  baseUrl: 'https://api.minipim.com',
  apiKey: process.env.MINIPIM_API_KEY!,
});

const { data, error } = await pim.GET('/v1/products/{id}', {
  params: { path: { id: productId }, query: { locale: 'en_US', channel: 'web' } },
});
if (error) throw new Error(error.error.message);
console.log(data.resolvedAttributes);

baseUrl is the origin only. Paths already include /v1. Path parameters use the names from the spec, such as {id}.

Client options

  • baseUrl (required).
  • apiKey: your pim_… API key. The key carries its organization, so organizationId is not needed with it.
  • organizationId: sent as x-organization-id, only for non-key authentication.
  • headers: extra headers on every request. fetch: a custom fetch, for example one that adds timeouts or retries.

The return value is a standard openapi-fetch client: GET, POST, PATCH, PUT, DELETE, each returning { data, error, response }.

Helpers

ExportUse
paginate(client, path, { query, pageSize })Async-iterate every item across pages (default page size 200)
collectAll(client, path, opts)Same, collected into an array
getAttribute(attributes, code, { locale, channel })Resolve one value with the server’s fallback order
flattenAttributes(attributes, { locale, channel })Client-side equivalent of resolvedAttributes, for list responses
asMoney, formatMoney, asMeasurementNarrow and format money (integer cents) and measurement values
getModifierChoices, getModifierPriceAdjuster, applyPriceAdjuster, formatPriceAdjusterRead modifier choices and price deltas
asRepeaterRowsRead a repeater value as typed rows; returns [] when unset
isMinipimError, getErrorMessageNarrow the error envelope
paths, components, operationsRaw generated types
import { paginate } from '@minipim/sdk';

for await (const product of paginate(pim, '/v1/products', { query: { status: 'active' } })) {
  await index(product);
}

Webhook verification

Import the verifier from a subpath so runtime-specific crypto stays out of your main bundle:

import { verifyMinipimWebhook } from '@minipim/sdk/webhook'; // Node, synchronous
// import { verifyMinipimWebhookEdge } from '@minipim/sdk/webhook-edge'; // Edge, returns a Promise

const raw = await req.text();
const ok = verifyMinipimWebhook({
  rawBody: raw,
  signature: req.headers.get('x-minipim-signature-256') ?? '',
  secret: process.env.MINIPIM_WEBHOOK_SECRET!,
});

Rules and limits

  • Pass the raw request body to the verifier. Re-serialized JSON will not match the signature. The Edge verifier is async, so await it; the Node one is not.
  • paginate follows hasMore. For endpoints that return a plain array it yields that array once and stops.
  • paginate always sends limit. On GET /v1/categories that turns the full-tree response into a single page of pageSize rows, so call pim.GET('/v1/categories') directly to get the whole tree.
  • Keep pageSize within the endpoint’s maximum (200 for products, content and brands). See Listing, filtering and pagination.
  • The client does not retry. Pass your own fetch if you want retries or timeouts.
  • Requires Node 18+ for the global fetch, or a polyfill passed as fetch.

The SDK is versioned separately from the API. The API reference is the source of the generated types.

See also

  • REST API basics — Base URL, authentication, JSON conventions, IDs, money and dates for the minipim /v1 REST API, plus where to find the live OpenAPI reference.
  • Listing, filtering and pagination — How minipim list endpoints page with limit, offset and hasMore, which ones return plain arrays, and the filters, sorts and limits /v1/products accepts.
  • Webhooks — Send signed minipim catalog events to your storefront: install the Headless connector, choose event groups, verify signatures, and debug deliveries.
  • Errors — The minipim API error envelope, every error code and HTTP status it uses, how validation issues are reported, and how to read per-item results from bulk calls.