DEVekspertiz.app

04 · Sayfalama (Cursor)

Liste endpoint'lerimiz opaque cursor kullanır — offset değil. Bu, insert'ler altında stable kalır ve büyük tablolarda performanslıdır.

Kullanım

GET /api/v1/partner/inspections?limit=25

Yanıt:

{
  "data": [...],
  "page": {
    "next_cursor": "eyJ0IjoiMjAyNi0wNS0xN1QyMTowMDowMC4wMDBaIiwiaSI6Imluc18uLi4ifQ",
    "has_more": true
  }
}

Sonraki sayfa:

GET /api/v1/partner/inspections?limit=25&cursor=eyJ0IjoiMjAyNi0wNS0xN1QyMTowMDowMC4wMDBaIiwiaSI6Imluc18uLi4ifQ

Kurallar

  • limit — 1..100, default 25.
  • cursor opaque — içeriğine güvenmeyin; geri gönderdiğiniz string olmalı.
  • has_more=false döndüğünde sayfa biter.
  • Sıralama: createdAt DESC, id DESC. Yeni raporlar daima ilk sayfada.

Tipik full sync döngüsü (Node.js)

let cursor = null;
do {
  const path = "/api/v1/partner/inspections?limit=100"
    + (cursor ? `&cursor=${encodeURIComponent(cursor)}` : "");
  const r = await partnerRequest({ path });
  for (const ins of r.body.data) {
    await processInspection(ins);
  }
  cursor = r.body.page.next_cursor;
} while (cursor);

Artımlı (incremental) sync

Sadece yeni eklenenleri çekmek için:

GET /api/v1/partner/inspections?published_from=2026-05-17T00:00:00Z&limit=100

Sonraki: 05 · PII maskeleme.