Pagination
Pages, page size, sort orders and how to keep a random order stable across pages in the CoworkingView API.
List endpoints such as GET /v1/properties are paginated. Everything you need is in the response meta.
Request parameters
| Parameter | Values | Default |
|---|---|---|
page | 1 to 500 | 1 |
pageSize | 1 to 50 | 20 |
sortBy | random, date-desc, date-asc, distance, price-asc | random |
seed | integer, 0 to 2147483647 | generated for you |
distance needs a position (lat and lng, see Properties). A value outside the ranges above is answered with a VALIDATION_FAILED error.
The response
{
"data": [ /* up to pageSize items */ ],
"meta": {
"contractVersion": "1.0.0",
"pagination": { "page": 2, "pageSize": 20, "total": 143, "pageCount": 8 },
"seed": 1234567
}
}| Field | Meaning |
|---|---|
pagination.page | The page you got. |
pagination.pageSize | The page size applied. |
pagination.total | How many items match in total, across all pages (not the length of data). |
pagination.pageCount | How many pages there are for this pageSize. |
seed | The seed used for sortBy=random. Echoed so you can reuse it. |
To walk all pages, request page=1 and go on until page equals pageCount. An empty result has total: 0 and an empty data.
Random order and the seed
The default order is random, so that no listing is always first. A random order that is re-shuffled on every request would repeat some items and skip others while you page through it. To prevent that, the API gives you a seed:
- On the first page, don't send a
seed. The response containsmeta.seed. - On every following page, send that same value as
seed, with the same filters andsortBy.
- 1.GET /v1/properties?locale=en&page=1
- 2.data (page 1) · meta.seed = 1234567
- 3.Keep the seed
- 4.GET /v1/properties?locale=en&page=2&seed=1234567
- 5.data (page 2), same order · meta.seed = 1234567
The other sort orders (date-desc, date-asc, distance, price-asc) are deterministic and don't need a seed.
const base = 'https://api.coworkingview.com/v1/properties?locale=en&city=berlin&pageSize=50';
let page = 1, seed: number | undefined, all: unknown[] = [];
for (;;) {
const url = `${base}&page=${page}${seed ? `&seed=${seed}` : ''}`;
const { data, meta } = await (await fetch(url)).json();
all.push(...data);
seed = meta.seed;
if (page >= meta.pagination.pageCount) break;
page += 1;
}Paging through the whole catalogue to copy it is not what the API is for: see Attribution and licences. Use filters to fetch what your product needs.
The map endpoint is not paginated
GET /v1/properties/map takes the same filters but returns every matching space as a light list of coordinates and titles, in one response. It ignores page and pageSize, and its meta.pagination always describes one page that holds everything.
The set it returns has a ceiling. When the ceiling cuts the result, meta.truncated is true. Don't present such a result as complete: narrow the filters (a city, a zone) and ask again. truncated is also true, with an empty list, if the map data was briefly unavailable.