Criminal Records API · v1.0.0

Pagination & response size

Top-level page and perPage, a 200-record page cap, and counts.records as the total.

Livehttps://api.offendersearch.appSandboxhttps://sandbox.offendersearch.app

page and perPage are top-level

page and perPage are top-level request fields, not inside query — a deliberate difference from the Sex Offender API. Sending them inside query silently gives you the defaults (page: 1, perPage: 50); nothing errors, so the mistake is quiet. They are echoed back at the top level exactly as you sent them, so a missing echo of your value is the sign they went in the wrong place.

ParameterWhereDefaultConstraint
pagerequest top level1>= 1; below it, 422 invalid_page
perPagerequest top level501–200; outside it, 422 invalid_page
The "inside query" gotcha. This is the single most common paging mistake against this endpoint. page/perPage inside query are ignored — you get page 1 of 50 and it looks like there is nothing more to fetch.
Where page / perPage go
// ✗ WRONG — page/perPage inside query are ignored; you get page 1, perPage 50
{ "query": { "lastName": "Hamilton", "state": "TX", "page": 3, "perPage": 200 } }

// ✓ RIGHT — page/perPage at the top level
{ "query": { "lastName": "Hamilton", "state": "TX" }, "page": 3, "perPage": 200 }

The per-page cap is 200

One response carries at most 200 records, so perPage is an integer from 1 to 200. Anything else — 0, 201, a string — is refused with 422 invalid_page, as is a page below 1. The echoed perPage and totalPages therefore always describe the pages you can walk.

A perPage outside 1–200
// perPage 300 (or 0, or "50") is refused before the search runs — and is not billed.
{ "error": { "code": "invalid_page",
             "message": "perPage must be from 1 to 200 (got 300)" } }
A cap is not a page. The 200-record ceiling is a slice size, not a limit on the answer — perPage slices a result you can walk in full. Read counts.records against counts.recordsReturned: if they differ, there is more to fetch. See counts.

counts.records is the total; records.length is the page

The two are different numbers and confusing them is the second common mistake:

FieldMeaning
counts.recordsThe total matched, before your page slice. It does not change as you page. Use it for "N results found".
counts.recordsReturnedHow many records this response carries — the current page. Equals records.length.
totalPagesceil(records / perPage), minimum 1. Authoritative — you do not compute it yourself.

Behaviour

  • counts.records is the total and does not change as you page. Walk page = 1 … totalPages to retrieve the whole result set; each record appears exactly once.
  • Every matching stored record is read for the surname, first name and location filters, and the whole result is ranked before it is paged. A common surname with nothing else to narrow it may be too broad to read in full within the time budget; then the search is refused with a 422 (error.code: query_too_broad) rather than answered partially. Add a firstName or a state.
  • Ordering is total and deterministic, so paging never reshuffles — two identical requests return the same records on the same pages. Records sort by matchTier (best first), then agreement with a residence hint you sent, then matchConfidence (descending), then surname, then first name, then externalId as the final stable tie-break. On a merged cached + live result the same key is applied after the merge. See Matching & confidence.
  • A page past the end returns an empty records array — page echoes the number you asked for, counts.records and totalPages are unchanged, and recordsReturned is 0. So while (records.length) page++ terminates.
Walking a 512-record result
// A 512-record result at perPage 200 spans 3 pages (ceil(512 / 200)).

// page 1 — full
{ "page": 1, "perPage": 200, "totalPages": 3,
  "counts": { "records": 512, "recordsReturned": 200 } }

// page 3 — the remainder
{ "page": 3, "perPage": 200, "totalPages": 3,
  "counts": { "records": 512, "recordsReturned": 112 } }

// page 99 — past the end: an empty slice, totals unchanged
{ "page": 99, "perPage": 200, "totalPages": 3,
  "counts": { "records": 512, "recordsReturned": 0 }, "records": [] }

Worked example — collecting a whole result set

Because totalPages is authoritative and ordering is stable, the safe loop is "fetch page 1, then walk to totalPages". Note that page/perPage ride at the top level of the body — the one detail this loop exists to get right:

Paging a cached result set
async function page(n) {
  const res = await fetch("https://api.offendersearch.app/v1/criminal/search", {
    method: "POST",
    headers: {
      "X-API-Key": process.env.OFFENDERSEARCH_KEY,
      "Content-Type": "application/json",
    },
    // ★ page / perPage are TOP-LEVEL — NOT inside query.
    body: JSON.stringify({
      query: { lastName: "Hamilton", state: "TX" },
      page: n,
      perPage: 200,
    }),
  });
  return res.json();
}

const first = await page(1);
// counts.records is the TOTAL before the slice; totalPages is authoritative.
const all = [...first.records];
for (let n = 2; n <= first.totalPages; n++) {
  const next = await page(n);        // next.page echoes the page you got
  all.push(...next.records);         // each record appears exactly once
}
// all.length === first.counts.records

Every page is its own search request and is billed as one criminal_call. A live search pages too — the merged (cached + live) result is ordered by the same total key — but each page request runs the live checks again and is billed as a live search, so ask for the page size you need on the first request. On a live search, still read counts.sourcesIncomplete before treating an empty page as a confirmed absence; paging tells you how many records there are, not whether every source was searched to the end. See Result completeness.

Product overview