Pagination, filters and delta sync
Every list answers the same envelope and pages with a cursor. With
updatedAfter, you fetch only what changed since your
last run.
The list envelope
JSON
{
"data": [ { "id": "product_…", "object": "product", "…": "…" } ],
"nextCursor": "eyJrIjoi…"
}
?limit=: the page size, 50 by default, 200 at most.-
?cursor=: thenextCursorof the previous page, sent back as it is. It is opaque: do not build or change one. -
The last page has no
nextCursor(absent ornull). There is no offset pagination. -
A cursor belongs to its list, filters and sort: send the same
ones with it, or you get
400 core.bad-request.
CLI
#!/usr/bin/env bash
# pagination-all-products: the myle CLI (key from `myle login` or MYLE_API_KEY).
# --all sends nextCursor back for you, up to the last page; --format jsonl prints one product per line.
myle products list --organization organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d \
--limit 200 --all --format jsonl \
| jq -r '[.id, .name] | @tsv'
HTTP (curl)
# Every product, page after page (needs jq).
url="https://api.myleapp.fr/organizations/organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d/products"
cursor=""
while :; do
page=$(curl -sS --fail-with-body -G "$url" \
-H "Authorization: Bearer $MYLE_API_KEY" \
--data-urlencode "limit=200" \
${cursor:+--data-urlencode "cursor=$cursor"})
jq -c '.data[]' <<<"$page"
cursor=$(jq -r '.nextCursor // empty' <<<"$page")
[ -n "$cursor" ] || break
done
TypeScript
import { Myle } from '@myleapp/myle';
const myle = new Myle();
const products = myle.organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d').products;
// The paginator sends nextCursor back for you, up to the last page.
for await (const product of products.list({ limit: 200 })) {
console.log(product.id, product.name);
}
Python
from myle import Myle
myle = Myle()
products = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products
# The paginator sends next_cursor back for you, up to the last page.
for product in products.list(limit=200):
print(product.id, product.name)
Go
package main
import (
"context"
"fmt"
"log"
myle "github.com/myleapp/myle-go"
)
func main() {
client := myle.NewClient()
products := client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").Products
// The paginator sends nextCursor back for you, up to the last page.
for product, err := range products.List(context.Background(), &myle.ProductListParams{Limit: myle.Int(200)}).All() {
if err != nil {
log.Fatal(err)
}
fmt.Println(product.ID, product.Name)
}
}
Java
import fr.myleapp.myle.MyleClient;
import fr.myleapp.myle.Product;
import fr.myleapp.myle.ProductListParams;
import fr.myleapp.myle.Products;
public class Example {
public static void main(String[] args) {
MyleClient client = MyleClient.builder().build();
Products products = client.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products();
// The paginator sends nextCursor back for you, up to the last page.
for (Product product : products.list(ProductListParams.builder().limit(200).build())) {
System.out.println(product.id() + " " + product.name());
}
}
}
Scala
import fr.myleapp.myle.MyleClient
import fr.myleapp.myle.models.ListProductsParams
object PaginationAllProducts {
def main(args: Array[String]): Unit = {
val myle = MyleClient()
val products = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products
// The paginator sends nextCursor back for you, up to the last page.
for (product <- products.list(ListProductsParams(limit = Some(200)))) {
println(s"${product.id} ${product.name}")
}
}
}
PHP
<?php
require __DIR__ . '/vendor/autoload.php';
use Myle\Client;
$myle = new Client();
$products = $myle->organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d')->products;
// The paginator sends nextCursor back for you, up to the last page.
foreach ($products->list(limit: 200) as $product) {
echo $product->id, ' ', $product->name, "\n";
}
C#
using Myle;
using var client = new MyleClient();
var products = client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").Products;
// The paginator sends nextCursor back for you, up to the last page.
await foreach (var product in products.ListAsync(new ProductListParams { Limit = 200 }))
{
Console.WriteLine($"{product.Id} {product.Name}");
}
Filters
-
A filter is named after the field it filters:
?status=ACTIVE,?companyId=company_…. -
Several values of one filter are repeated, and mean “any of”:
?tag=Bio&tag=Local. -
A date range takes the field name with
FromandTo, both inclusive:?issueDateFrom=2026-10-01&issueDateTo=2026-10-31. ?q=is a text search, when a list offers one.
Each list documents its own filters in the reference. The products,
for example, take q (name or number, accents and case
ignored), status, tag, barcode
(exact) and updatedAfter.
Sorting
?sort= takes a field, with a leading - for
descending: ?sort=-updatedAt. Only the fields a list
documents can be sorted on; the products take name (the
default), -name, updatedAt and
-updatedAt.
Delta sync with updatedAfter
To keep a copy of Myle's data (in an accounting tool, a CRM, a warehouse) without reading everything every time:
-
The first time, read the whole list with
sort=updatedAt, oldest change first, and remember the largestupdatedAtyou stored. -
Next time, ask for
?updatedAfter=<that instant>&sort=updatedAtand follow the cursors to the end.updatedAfteris strict: it returns what changed after that instant. -
Write each resource by its
id(insert or update), so reading one twice does no harm.
CLI
#!/usr/bin/env bash
# pagination-delta-sync: the myle CLI (key from `myle login` or MYLE_API_KEY).
# The largest updatedAt stored by the last run, a few minutes earlier.
since=2026-11-20T23:00:00Z
myle products list --organization organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d \
--updated-after "$since" --sort updatedAt --limit 200 --all --format jsonl \
| jq -r '[.id, .updatedAt] | @tsv' \
| {
while IFS=$'\t' read -r id updated_at; do
echo "upsert $id $updated_at" # write it by its id
since=$updated_at
done
echo "next run: updatedAfter = $since"
}
HTTP (curl)
curl "https://api.myleapp.fr/organizations/organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d/products?updatedAfter=2026-11-20T23:00:00Z&sort=updatedAt&limit=200" \
-H "Authorization: Bearer $MYLE_API_KEY"
TypeScript
import { Myle } from '@myleapp/myle';
const myle = new Myle();
const products = myle.organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d').products;
// The largest updatedAt stored by the last run, a few minutes earlier.
let since = '2026-11-20T23:00:00Z';
for await (const product of products.list({ updatedAfter: since, sort: 'updatedAt', limit: 200 })) {
console.log('upsert', product.id, product.updatedAt); // write it by its id
since = product.updatedAt;
}
console.log('next run: updatedAfter =', since);
Python
from myle import Myle
myle = Myle()
products = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products
# The largest updatedAt stored by the last run, a few minutes earlier.
since = "2026-11-20T23:00:00Z"
for product in products.list(updated_after=since, sort="updatedAt", limit=200):
print("upsert", product.id, product.updated_at) # write it by its id
since = product.updated_at
print("next run: updated_after =", since)
Go
package main
import (
"context"
"fmt"
"log"
myle "github.com/myleapp/myle-go"
)
func main() {
client := myle.NewClient()
products := client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").Products
// The largest updatedAt stored by the last run, a few minutes earlier.
since := "2026-11-20T23:00:00Z"
params := &myle.ProductListParams{UpdatedAfter: myle.String(since), Sort: myle.Value(myle.ProductListSortUpdatedAt), Limit: myle.Int(200)}
for product, err := range products.List(context.Background(), params).All() {
if err != nil {
log.Fatal(err)
}
fmt.Println("upsert", product.ID, product.UpdatedAt) // write it by its id
since = product.UpdatedAt
}
fmt.Println("next run: UpdatedAfter =", since)
}
Java
import fr.myleapp.myle.MyleClient;
import fr.myleapp.myle.Product;
import fr.myleapp.myle.ProductListParams;
import fr.myleapp.myle.ProductSort;
import fr.myleapp.myle.Products;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
MyleClient client = MyleClient.builder().build();
Products products = client.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products();
// The largest updatedAt stored by the last run, a few minutes earlier.
OffsetDateTime since = OffsetDateTime.parse("2026-11-20T23:00:00Z");
ProductListParams params = ProductListParams.builder()
.updatedAfter(since).sort(ProductSort.UPDATED_AT).limit(200).build();
for (Product product : products.list(params)) {
System.out.println("upsert " + product.id() + " " + product.updatedAt()); // write it by its id
since = product.updatedAt();
}
System.out.println("next run: updatedAfter = " + since);
}
}
Scala
import fr.myleapp.myle.MyleClient
import fr.myleapp.myle.models.{ListProductsParams, ProductSort}
object PaginationDeltaSync {
def main(args: Array[String]): Unit = {
val myle = MyleClient()
val products = myle.organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").products
// The largest updatedAt stored by the last run, a few minutes earlier.
var since = "2026-11-20T23:00:00Z"
val changed = ListProductsParams(updatedAfter = Some(since), sort = Some(ProductSort.UpdatedAt), limit = Some(200))
for (product <- products.list(changed)) {
println(s"upsert ${product.id} ${product.updatedAt}") // write it by its id
since = product.updatedAt
}
println(s"next run: updatedAfter = $since")
}
}
PHP
<?php
require __DIR__ . '/vendor/autoload.php';
use Myle\Client;
$myle = new Client();
$products = $myle->organization('organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d')->products;
// The largest updatedAt stored by the last run, a few minutes earlier.
$since = '2026-11-20T23:00:00Z';
foreach ($products->list(updatedAfter: $since, sort: 'updatedAt', limit: 200) as $product) {
echo 'upsert ', $product->id, ' ', $product->updatedAt, "\n"; // write it by its id
$since = $product->updatedAt;
}
echo 'next run: updatedAfter = ', $since, "\n";
C#
using Myle;
using var client = new MyleClient();
var products = client.Organization("organization_7f2c41d0-8a3b-4c6e-9f12-5d7e8a9b0c1d").Products;
// The largest UpdatedAt stored by the last run, a few minutes earlier.
var since = new DateTimeOffset(2026, 11, 20, 23, 0, 0, TimeSpan.Zero);
await foreach (var product in products.ListAsync(
new ProductListParams { UpdatedAfter = since, Sort = ProductSort.UpdatedAt, Limit = 200 }))
{
Console.WriteLine($"upsert {product.Id} {product.UpdatedAt:O}"); // write it by its id
since = product.UpdatedAt;
}
Console.WriteLine($"next run: UpdatedAfter = {since:O}");
Overlap a little. Start each run a few minutes
before the last instant you stored, and skip what you already have
with the same id and updatedAt. A change
committed while your previous run was reading can carry an instant
just before its end.
Deletions do not appear in a delta: a deleted
resource is simply no longer returned, and reading it answers
404. To catch them, compare a full listing of the ids
with your copy from time to time, for example once a week.
What moves updatedAt is described per resource in the
reference: for a product, a change of its barcodes does not count.
updatedAfter works on the products, the customers
(companies) and the invoices, and on their searches
across every organization the credential can read
(GET /invoices, GET /companies,
GET /products, narrowed with
?organizationId=…): each item there says its
organizationId.