Developers
Start building
APIs/App API/Make your first API call

Make your first API call

How your server gets an App API token and lists the store's products.

On this page

The App API is called from your server with an access token from Poltura ID: your app's own (the JWT profile with its machine user) or a person's through your app. Every call names the store installation in Poltura-Installation. See Auth for both.

PolturaClient from @poltura/app-sdk sends the token and the installation to /apps-api/v1. Read the store, then walk the product list page by page until nextCursor is null:

server.ts
async function listAllProducts(client: PolturaClient): Promise<string[]> {
  const titles: string[] = [];
  let cursor: string | undefined;
  do {
    const page = await client.products.list({ limit: 100, cursor });
    titles.push(...page.products.map((product) => product.title));
    cursor = page.nextCursor ?? undefined;
  } while (cursor !== undefined);
  return titles;
}

What to know next

  • Errors come back as PolturaRequestError with a code, the HTTP status and a requestId to quote when you ask for help. rate_limited carries retryAfterMs. The full list is on App API.
  • Writes take an Idempotency-Key, so a retried request is applied once. Storage writes also take the expectedVersion they are based on.
  • Webhooks tell you when products or orders change, so you do not have to poll. See Webhooks.
Last updated