Search
Pagination
Use the limit and offset query parameters to page through search and find results.
POST /v1/search and GET /v1/find return one page of results at a time. You control the page with two query parameters:
| Parameter | Default | Max | Description |
|---|---|---|---|
| limit | 20 | 100 | Results per page. Larger values are capped at 100. |
| offset | 0 | Zero-based page number. |
offset is a page number
offset counts pages, not results. With limit=20, offset=1 returns
results 21-40 and offset=2 returns 41-60. Keep limit the same on every
page.
For search, these go in the query string, not the JSON body:
curl -X POST "https://api.inbe.us/v1/search?limit=20&offset=1" \
-H "Content-Type: application/json" \
-H "API-Key: $INBE_API_KEY" \
-d '{
"locations": [{ "lat": 51.5081, "lon": -0.1278 }],
"mode": { "mode": "POINT", "maxDistance": 1000 }
}'Knowing when to stop
Each response tells you where you are:
{
"totalFound": 57,
"page": 1,
"establishments": [ ... ]
}totalFound: venues matching your search across all pages.page: the page returned (same asoffset).
The last page is ceil(totalFound / limit) - 1. A page past the end returns an empty establishments array.
Fetching every page
async function searchAll(body: object, limit = 20, maxPages = 5) {
const results = [];
for (let offset = 0; offset < maxPages; offset++) {
const res = await fetch(
`https://api.inbe.us/v1/search?limit=${limit}&offset=${offset}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"API-Key": process.env.INBE_API_KEY!,
},
body: JSON.stringify(body),
},
);
const page = await res.json();
results.push(...page.establishments);
if ((offset + 1) * limit >= page.totalFound) break;
}
return results;
}import os
import requests
def search_all(body, limit=20, max_pages=5):
results = []
for offset in range(max_pages):
page = requests.post(
"https://api.inbe.us/v1/search",
params={"limit": limit, "offset": offset},
headers={"API-Key": os.environ["INBE_API_KEY"]},
json=body,
timeout=10,
).json()
results.extend(page["establishments"])
if (offset + 1) * limit >= page["totalFound"]:
break
return resultsTips
- Send the same body for every page. Changing locations or preferences between pages changes the result set.
- Fetch pages when you need them. Most users only look at the first page, so load the next one as they scroll.
- Each page is a separate charge. Every page you fetch is billed as another request, so a larger
limitis cheaper than fetching several small pages. See Billing.