Pagination and sorting
Page through API v2 lists with page and per_page, read the meta block, and sort orders with the sort parameter.
Last updated
Pagination
Section titled “Pagination”List endpoints take two query parameters:
| Parameter | Default | |
|---|---|---|
page |
1 |
Page number, starting at 1. |
per_page |
50 |
Records per page. The maximum is 200. |
The response wraps the records in data and describes the paging in meta:
{ "data": [ { "id": "3e84eb8d-e1d9-4e92-a4b2-a419c7f1122f", "name": "#1077" } ], "meta": { "total_count": 1284, "page": 1, "per_page": 50, "total_pages": 26 }}To read everything, keep requesting page + 1 until page reaches total_pages:
let page = 1;let totalPages = 1;const orders = [];while (page <= totalPages) { const response = await fetch( `https://app.filemonk.io/api/v2/external/orders?per_page=200&page=${page}`, { headers: { 'X-Auth-Token': 'fm_api_key_your_key_here' } } ); const body = await response.json(); orders.push(...body.data); totalPages = body.meta.total_pages; page += 1;}Each page is one read (1 point), so a large per_page is the cheapest way to read a lot. To only count records, ask for one and read meta.total_count:
curl 'https://app.filemonk.io/api/v2/external/orders?per_page=1' \ -H 'X-Auth-Token: fm_api_key_your_key_here'Sorting
Section titled “Sorting”Lists are newest first unless the action documents a sort. GET /orders takes a sort parameter made of a field and a direction, separated by a space:
| Value | Order |
|---|---|
ordered_at desc |
Newest purchase first. The default. |
ordered_at asc |
Oldest purchase first. |
created_at desc / created_at asc |
By when Filemonk recorded the order, which can differ from when the buyer ordered (for example on imported orders). |
name asc / name desc |
By order name. |
email asc / email desc |
By buyer email. |
notified_at asc / notified_at desc |
By when the download email was last sent. |
ordered_at is when the buyer placed the order. created_at is when the order was saved in Filemonk.
curl 'https://app.filemonk.io/api/v2/external/orders?sort=ordered_at%20asc&per_page=100' \ -H 'X-Auth-Token: fm_api_key_your_key_here'Order ids and the #
Section titled “Order ids and the #”A # starts a fragment in a URL, so an order name such as #1042 must be written %231042 when you use it in a path:
curl 'https://app.filemonk.io/api/v2/external/orders/%231042/troubleshoot' \ -H 'X-Auth-Token: fm_api_key_your_key_here'In a query string the same applies: ?search=%231042. In a JSON body there is no problem, write "#1042" as it is.
Thanks for letting us know.
Still stuck? Ask Quinn or chat with support