CartirraAPI
Get API keys

Core concepts

Pagination and filtering

Lists are newest first and use cursors. Ask for up to 100 items a page and follow next_cursor.

Every list endpoint, such as GET /v1/orders, GET /v1/customers and GET /v1/events, returns one page:

{
  "data": [ { "id": "ord_…" }, { "id": "ord_…" } ],
  "next_cursor": "0193a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a5b"
}
ParameterMeaning
limitItems per page, 1–100. Defaults to 25.
cursorThe next_cursor from the previous page. Leave it out for the first page.

next_cursor is null on the last page. Cursors are opaque: pass them back exactly as you got them. They stay valid as new items arrive, so you won't see an item twice or skip one while paging.

Fetch every page

async function* allOrders(params = {}) {
  let cursor;
  do {
    const query = new URLSearchParams({ limit: '100', ...params, ...(cursor ? { cursor } : {}) });
    const response = await fetch(`https://api.cartirra.com/v1/orders?${query}`, {
      headers: { Authorization: `Bearer ${process.env.CARTIRRA_SECRET_KEY}` },
    });
    if (!response.ok) throw new Error((await response.json()).error.code);
    const page = await response.json();
    yield* page.data;
    cursor = page.next_cursor;
  } while (cursor);
}

for await (const order of allOrders({ payment_status: 'paid' })) console.log(order.reference);
<?php
$cursor = null;
do {
    $query = http_build_query(array_filter(['limit' => 100, 'cursor' => $cursor]));
    $ch = curl_init("https://api.cartirra.com/v1/orders?$query");
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('CARTIRRA_SECRET_KEY')],
    ]);
    $page = json_decode(curl_exec($ch), true);
    foreach ($page['data'] as $order) echo $order['reference'], PHP_EOL;
    $cursor = $page['next_cursor'];
} while ($cursor);

Filters

Lists take filters as query parameters, documented on each endpoint. For example, GET /v1/orders filters by status, payment_status, store_id, customer_id and q (an order reference). Filters combine with AND, and paging keeps the same filters: send them with every page.

Some lists add their own fields beside data. For example, GET /v1/reviews also returns a rating summary.