Getting started
Pagination
GET /v1/orders returns the newest orders first, a page at a time.
How it works
limitsets how many orders you get (1–100, default 25).hasMoreistruewhen there are more orders after this page.- To get the next page, send the id of the last order you got as
starting_after.
Example
Fetch every paid order, 100 at a time:
JavaScript
const orders = [];
let after = "";
while (true) {
const res = await fetch(`https://api.craftpay.net/v1/orders?status=paid&limit=100${after && `&starting_after=${after}`}`, {
headers: { Authorization: `Bearer ${process.env.CRAFTPAY_KEY}` },
});
const page = await res.json();
orders.push(...page.data);
if (!page.hasMore) break;
after = page.data.at(-1).id;
}Stuck? Write to mail@craftpay.net