Install
Quickstart
Create an item, then list stock on hand:Authentication
Pass an API key or an OAuth access token astoken. Create an API key in the app under Settings > Access > API keys. The key acts as the member who made it, and a call needs both the member’s permission and one of the key’s scopes.
For an OAuth token that expires, pass a function. The client calls it before each request:
Making calls
There is one method for each HTTP method:get, post, put, patch and delete. Each takes a path as the API reference writes it. Fill in path parameters with path, the query string with query and the JSON body with body:
undefined, a CSV export to its text and a file to the raw Response.
Every schema in the reference has a type under Schemas:
Pagination
A list that can grow returns one page at a time.paginate() follows the cursors and yields each record:
next_cursor back as query.after until it is null.
Errors
A failed call throws anApiError that holds the RFC 9457 problem details body. Branch on code, which is stable. detail is written for people and may change.
ApiError also has status, problem and headers. A call that gets no answer, because the network failed or the attempt timed out, throws a ConnectionError.
Retries and idempotency keys
The client retries a429 after the time in Retry-After. It does this for every method, because the API did not run the call. If Retry-After is longer than maxRetryAfter, it throws instead.
A 5xx or a network failure is retried for GET, PUT and DELETE, with a short backoff. A POST or PATCH is retried only when you give it an idempotency key, so a retry cannot make the change twice:
Webhooks
Check theStockShift-Signature header before you trust a delivery. verifyWebhook() needs the raw body, exactly as it arrived:
tolerance, in seconds, to change that. Retries of an event keep its id, so store it and skip events you have handled.
To test your own receiver, signWebhook() signs a payload the same way StockShift does.
Versions
The major version moves when the API changes in a way that can break your code, such as a removed field or a new required parameter. New endpoints and fields come in minor versions.API_VERSION holds the version of the API reference the package was built from.