[{"data":1,"prerenderedAt":700},["ShallowReactive",2],{"page:\u002Fpagination":3},{"id":4,"title":5,"body":6,"description":691,"extension":692,"meta":693,"navigation":469,"operation":694,"path":695,"rawbody":696,"seo":697,"stem":698,"__hash__":699},"docs\u002Fpagination.md","Pagination",{"type":7,"value":8,"toc":684},"minimark",[9,13,76,91,100,106,163,167,175,440,444,449,659,663,670,680],[10,11,12],"p",{},"List endpoints return results in pages, controlled by two query parameters:",[14,15,16,35],"table",{},[17,18,19],"thead",{},[20,21,22,26,29,32],"tr",{},[23,24,25],"th",{},"Parameter",[23,27,28],{},"Default",[23,30,31],{},"Range",[23,33,34],{},"Meaning",[36,37,38,58],"tbody",{},[20,39,40,47,52,55],{},[41,42,43],"td",{},[44,45,46],"code",{},"limit",[41,48,49],{},[44,50,51],{},"100",[41,53,54],{},"1–1000",[41,56,57],{},"Maximum number of results in the page.",[20,59,60,65,70,73],{},[41,61,62],{},[44,63,64],{},"offset",[41,66,67],{},[44,68,69],{},"0",[41,71,72],{},"≥ 0",[41,74,75],{},"Number of results to skip.",[10,77,78,79,86,87,90],{},"A value outside its range returns ",[80,81,83],"a",{"href":82},"\u002Ferrors#validation-errors",[44,84,85],{},"422",". There are no cursors or ",[44,88,89],{},"next"," links.",[92,93,95,96,99],"h2",{"id":94},"what-count-means","What ",[44,97,98],{},"count"," means",[10,101,102,103,105],{},"The two list endpoints report ",[44,104,98],{}," differently. Write your loop for the endpoint you call.",[14,107,108,122],{},[17,109,110],{},[20,111,112,115,118],{},[23,113,114],{},"Endpoint",[23,116,117],{},"Order",[23,119,120],{},[44,121,98],{},[36,123,124,146],{},[20,125,126,132,139],{},[41,127,128],{},[80,129,131],{"href":130},"\u002Fproperties\u002Flist","List properties",[41,133,134,135,138],{},"Last updated first, unless ",[44,136,137],{},"sort"," is set",[41,140,141,145],{},[142,143,144],"strong",{},"Total"," matching properties, across all pages",[20,147,148,154,157],{},[41,149,150],{},[80,151,153],{"href":152},"\u002Fleads\u002Flist","List leads",[41,155,156],{},"Newest first",[41,158,159,160],{},"Number of leads ",[142,161,162],{},"in this page",[92,164,166],{"id":165},"paging-through-properties","Paging through properties",[10,168,169,171,172,174],{},[44,170,98],{}," is the total, so stop when ",[44,173,64],{}," reaches it:",[176,177,183],"pre",{"className":178,"code":179,"filename":180,"language":181,"meta":182,"style":182},"language-javascript shiki shiki-themes github-light","async function listAllProperties() {\n  const properties = []\n  const limit = 100\n  for (let offset = 0; ; offset += limit) {\n    const url = `https:\u002F\u002Fapi.vestta.app\u002Fv1\u002Fext\u002Fproperties?limit=${limit}&offset=${offset}`\n    const response = await fetch(url, { headers: { 'X-Api-Key': process.env.VESTTA_API_KEY } })\n    if (!response.ok) throw new Error(`Vestta API ${response.status}`)\n    const page = await response.json()\n    properties.push(...page.data)\n    if (offset + limit >= page.count) return properties\n  }\n}\n","JavaScript","javascript","",[44,184,185,205,221,234,264,289,320,364,385,402,428,434],{"__ignoreMap":182},[186,187,190,194,197,201],"span",{"class":188,"line":189},"line",1,[186,191,193],{"class":192},"sD7c4","async",[186,195,196],{"class":192}," function",[186,198,200],{"class":199},"s7eDp"," listAllProperties",[186,202,204],{"class":203},"sgsFI","() {\n",[186,206,208,211,215,218],{"class":188,"line":207},2,[186,209,210],{"class":192},"  const",[186,212,214],{"class":213},"sYu0t"," properties",[186,216,217],{"class":192}," =",[186,219,220],{"class":203}," []\n",[186,222,224,226,229,231],{"class":188,"line":223},3,[186,225,210],{"class":192},[186,227,228],{"class":213}," limit",[186,230,217],{"class":192},[186,232,233],{"class":213}," 100\n",[186,235,237,240,243,246,249,252,255,258,261],{"class":188,"line":236},4,[186,238,239],{"class":192},"  for",[186,241,242],{"class":203}," (",[186,244,245],{"class":192},"let",[186,247,248],{"class":203}," offset ",[186,250,251],{"class":192},"=",[186,253,254],{"class":213}," 0",[186,256,257],{"class":203},"; ; offset ",[186,259,260],{"class":192},"+=",[186,262,263],{"class":203}," limit) {\n",[186,265,267,270,273,275,279,281,284,286],{"class":188,"line":266},5,[186,268,269],{"class":192},"    const",[186,271,272],{"class":213}," url",[186,274,217],{"class":192},[186,276,278],{"class":277},"sYBdl"," `https:\u002F\u002Fapi.vestta.app\u002Fv1\u002Fext\u002Fproperties?limit=${",[186,280,46],{"class":203},[186,282,283],{"class":277},"}&offset=${",[186,285,64],{"class":203},[186,287,288],{"class":277},"}`\n",[186,290,292,294,297,299,302,305,308,311,314,317],{"class":188,"line":291},6,[186,293,269],{"class":192},[186,295,296],{"class":213}," response",[186,298,217],{"class":192},[186,300,301],{"class":192}," await",[186,303,304],{"class":199}," fetch",[186,306,307],{"class":203},"(url, { headers: { ",[186,309,310],{"class":277},"'X-Api-Key'",[186,312,313],{"class":203},": process.env.",[186,315,316],{"class":213},"VESTTA_API_KEY",[186,318,319],{"class":203}," } })\n",[186,321,323,326,328,331,334,337,340,343,346,349,352,355,358,361],{"class":188,"line":322},7,[186,324,325],{"class":192},"    if",[186,327,242],{"class":203},[186,329,330],{"class":192},"!",[186,332,333],{"class":203},"response.ok) ",[186,335,336],{"class":192},"throw",[186,338,339],{"class":192}," new",[186,341,342],{"class":199}," Error",[186,344,345],{"class":203},"(",[186,347,348],{"class":277},"`Vestta API ${",[186,350,351],{"class":203},"response",[186,353,354],{"class":277},".",[186,356,357],{"class":203},"status",[186,359,360],{"class":277},"}`",[186,362,363],{"class":203},")\n",[186,365,367,369,372,374,376,379,382],{"class":188,"line":366},8,[186,368,269],{"class":192},[186,370,371],{"class":213}," page",[186,373,217],{"class":192},[186,375,301],{"class":192},[186,377,378],{"class":203}," response.",[186,380,381],{"class":199},"json",[186,383,384],{"class":203},"()\n",[186,386,388,391,394,396,399],{"class":188,"line":387},9,[186,389,390],{"class":203},"    properties.",[186,392,393],{"class":199},"push",[186,395,345],{"class":203},[186,397,398],{"class":192},"...",[186,400,401],{"class":203},"page.data)\n",[186,403,405,407,410,413,416,419,422,425],{"class":188,"line":404},10,[186,406,325],{"class":192},[186,408,409],{"class":203}," (offset ",[186,411,412],{"class":192},"+",[186,414,415],{"class":203}," limit ",[186,417,418],{"class":192},">=",[186,420,421],{"class":203}," page.count) ",[186,423,424],{"class":192},"return",[186,426,427],{"class":203}," properties\n",[186,429,431],{"class":188,"line":430},11,[186,432,433],{"class":203},"  }\n",[186,435,437],{"class":188,"line":436},12,[186,438,439],{"class":203},"}\n",[92,441,443],{"id":442},"paging-through-leads","Paging through leads",[10,445,446,448],{},[44,447,98],{}," is the size of the page, so stop at the first page that is not full:",[176,450,455],{"className":451,"code":452,"filename":453,"language":454,"meta":182,"style":182},"language-python shiki shiki-themes github-light","import os\n\nimport requests\n\ndef list_all_leads():\n    leads, limit, offset = [], 100, 0\n    while True:\n        response = requests.get(\n            \"https:\u002F\u002Fapi.vestta.app\u002Fv1\u002Fext\u002Fleads\",\n            headers={\"X-Api-Key\": os.environ[\"VESTTA_API_KEY\"]},\n            params={\"limit\": limit, \"offset\": offset},\n        )\n        response.raise_for_status()\n        page = response.json()\n        leads.extend(page[\"data\"])\n        if page[\"count\"] \u003C limit:\n            return leads\n        offset += limit\n","Python","python",[44,456,457,465,471,478,482,493,511,522,532,540,563,584,589,595,606,618,639,648],{"__ignoreMap":182},[186,458,459,462],{"class":188,"line":189},[186,460,461],{"class":192},"import",[186,463,464],{"class":203}," os\n",[186,466,467],{"class":188,"line":207},[186,468,470],{"emptyLinePlaceholder":469},true,"\n",[186,472,473,475],{"class":188,"line":223},[186,474,461],{"class":192},[186,476,477],{"class":203}," requests\n",[186,479,480],{"class":188,"line":236},[186,481,470],{"emptyLinePlaceholder":469},[186,483,484,487,490],{"class":188,"line":266},[186,485,486],{"class":192},"def",[186,488,489],{"class":199}," list_all_leads",[186,491,492],{"class":203},"():\n",[186,494,495,498,500,503,505,508],{"class":188,"line":291},[186,496,497],{"class":203},"    leads, limit, offset ",[186,499,251],{"class":192},[186,501,502],{"class":203}," [], ",[186,504,51],{"class":213},[186,506,507],{"class":203},", ",[186,509,510],{"class":213},"0\n",[186,512,513,516,519],{"class":188,"line":322},[186,514,515],{"class":192},"    while",[186,517,518],{"class":213}," True",[186,520,521],{"class":203},":\n",[186,523,524,527,529],{"class":188,"line":366},[186,525,526],{"class":203},"        response ",[186,528,251],{"class":192},[186,530,531],{"class":203}," requests.get(\n",[186,533,534,537],{"class":188,"line":387},[186,535,536],{"class":277},"            \"https:\u002F\u002Fapi.vestta.app\u002Fv1\u002Fext\u002Fleads\"",[186,538,539],{"class":203},",\n",[186,541,542,546,548,551,554,557,560],{"class":188,"line":404},[186,543,545],{"class":544},"sqxcx","            headers",[186,547,251],{"class":192},[186,549,550],{"class":203},"{",[186,552,553],{"class":277},"\"X-Api-Key\"",[186,555,556],{"class":203},": os.environ[",[186,558,559],{"class":277},"\"VESTTA_API_KEY\"",[186,561,562],{"class":203},"]},\n",[186,564,565,568,570,572,575,578,581],{"class":188,"line":430},[186,566,567],{"class":544},"            params",[186,569,251],{"class":192},[186,571,550],{"class":203},[186,573,574],{"class":277},"\"limit\"",[186,576,577],{"class":203},": limit, ",[186,579,580],{"class":277},"\"offset\"",[186,582,583],{"class":203},": offset},\n",[186,585,586],{"class":188,"line":436},[186,587,588],{"class":203},"        )\n",[186,590,592],{"class":188,"line":591},13,[186,593,594],{"class":203},"        response.raise_for_status()\n",[186,596,598,601,603],{"class":188,"line":597},14,[186,599,600],{"class":203},"        page ",[186,602,251],{"class":192},[186,604,605],{"class":203}," response.json()\n",[186,607,609,612,615],{"class":188,"line":608},15,[186,610,611],{"class":203},"        leads.extend(page[",[186,613,614],{"class":277},"\"data\"",[186,616,617],{"class":203},"])\n",[186,619,621,624,627,630,633,636],{"class":188,"line":620},16,[186,622,623],{"class":192},"        if",[186,625,626],{"class":203}," page[",[186,628,629],{"class":277},"\"count\"",[186,631,632],{"class":203},"] ",[186,634,635],{"class":192},"\u003C",[186,637,638],{"class":203}," limit:\n",[186,640,642,645],{"class":188,"line":641},17,[186,643,644],{"class":192},"            return",[186,646,647],{"class":203}," leads\n",[186,649,651,654,656],{"class":188,"line":650},18,[186,652,653],{"class":203},"        offset ",[186,655,260],{"class":192},[186,657,658],{"class":203}," limit\n",[92,660,662],{"id":661},"consistency","Consistency",[10,664,665,666,669],{},"Pages are computed when each request arrives. If properties or leads change while you page through them, a result can move between pages and be skipped or returned twice. When you need a complete, exact copy, de-duplicate by ",[44,667,668],{},"id",", and run the sync again later rather than relying on a single pass.",[10,671,672,673,676,677,679],{},"Filters are applied before pagination, including the map areas of ",[80,674,131],{"href":675},"\u002Fproperties\u002Flist#map-areas",": ",[44,678,98],{}," and the pages only contain matching properties.",[681,682,683],"style",{},"html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html pre.shiki code .s7eDp, html code.shiki .s7eDp{--shiki-default:#6F42C1}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sqxcx, html code.shiki .sqxcx{--shiki-default:#E36209}",{"title":182,"searchDepth":223,"depth":223,"links":685},[686,688,689,690],{"id":94,"depth":207,"text":687},"What count means",{"id":165,"depth":207,"text":166},{"id":442,"depth":207,"text":443},{"id":661,"depth":207,"text":662},"Page through properties and leads with limit and offset.","md",{},null,"\u002Fpagination","---\ntitle: Pagination\ndescription: Page through properties and leads with limit and offset.\n---\n\nList endpoints return results in pages, controlled by two query parameters:\n\n| Parameter | Default | Range | Meaning |\n| --- | --- | --- | --- |\n| `limit` | `100` | 1–1000 | Maximum number of results in the page. |\n| `offset` | `0` | ≥ 0 | Number of results to skip. |\n\nA value outside its range returns [`422`](\u002Ferrors#validation-errors). There are no cursors or `next` links.\n\n## What `count` means\n\nThe two list endpoints report `count` differently. Write your loop for the endpoint you call.\n\n| Endpoint | Order | `count` |\n| --- | --- | --- |\n| [List properties](\u002Fproperties\u002Flist) | Last updated first, unless `sort` is set | **Total** matching properties, across all pages |\n| [List leads](\u002Fleads\u002Flist) | Newest first | Number of leads **in this page** |\n\n## Paging through properties\n\n`count` is the total, so stop when `offset` reaches it:\n\n```javascript [JavaScript]\nasync function listAllProperties() {\n  const properties = []\n  const limit = 100\n  for (let offset = 0; ; offset += limit) {\n    const url = `https:\u002F\u002Fapi.vestta.app\u002Fv1\u002Fext\u002Fproperties?limit=${limit}&offset=${offset}`\n    const response = await fetch(url, { headers: { 'X-Api-Key': process.env.VESTTA_API_KEY } })\n    if (!response.ok) throw new Error(`Vestta API ${response.status}`)\n    const page = await response.json()\n    properties.push(...page.data)\n    if (offset + limit >= page.count) return properties\n  }\n}\n```\n\n## Paging through leads\n\n`count` is the size of the page, so stop at the first page that is not full:\n\n```python [Python]\nimport os\n\nimport requests\n\ndef list_all_leads():\n    leads, limit, offset = [], 100, 0\n    while True:\n        response = requests.get(\n            \"https:\u002F\u002Fapi.vestta.app\u002Fv1\u002Fext\u002Fleads\",\n            headers={\"X-Api-Key\": os.environ[\"VESTTA_API_KEY\"]},\n            params={\"limit\": limit, \"offset\": offset},\n        )\n        response.raise_for_status()\n        page = response.json()\n        leads.extend(page[\"data\"])\n        if page[\"count\"] \u003C limit:\n            return leads\n        offset += limit\n```\n\n## Consistency\n\nPages are computed when each request arrives. If properties or leads change while you page through them, a result can move between pages and be skipped or returned twice. When you need a complete, exact copy, de-duplicate by `id`, and run the sync again later rather than relying on a single pass.\n\nFilters are applied before pagination, including the map areas of [List properties](\u002Fproperties\u002Flist#map-areas): `count` and the pages only contain matching properties.\n",{"title":5,"description":691},"pagination","M_w2n-2iLQGHfIwmYfFu5lKl12yEp-M4gZkjkD1ER4M",1791110048804]