Paginate results
Use limit and offset to page through search results.
import { Etoile } from "@etoile-dev/client";
const etoile = new Etoile({
apiKey: process.env.ETOILE_PUBLIC_KEY,
});
// First page: 10 results
const page1 = await etoile.search({
query: "landscape painting",
collections: ["paintings"],
limit: 10,
offset: 0,
});
// Second page: next 10
const page2 = await etoile.search({
query: "landscape painting",
collections: ["paintings"],
limit: 10,
offset: 10,
});// First page
const response = await fetch("https://etoile.dev/api/v1/search", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ETOILE_PUBLIC_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: "landscape painting",
collections: ["paintings"],
limit: 10,
offset: 0,
}),
});
const { results } = await response.json();curl -X POST "https://etoile.dev/api/v1/search" \
-H "Authorization: Bearer $ETOILE_PUBLIC_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "landscape painting",
"collections": ["paintings"],
"limit": 10,
"offset": 0
}'Related
- Search (POST) — API reference
- Search — basic search example