Skip to main content
A search runs in the background and adds results as it finds them. This guide shows how to wait for a search and read everything it found, without missing a result or reading one twice.
You need the id of a search you started. See the quickstart. Reading status and results is free, so the code here spends nothing.

The two signals

Two fields answer two different questions. Confusing them is an easy way to miss results. has_more: false while the search is running means you have read everything found so far. The search is not finished, and more results may arrive.

Wait, then read everything

The simplest approach is to wait until the search reaches a , then read every page of results. Each page ends with a that fetches the next one.
Pass "people" as kind for a people search. Everything else is the same.

Stream results as they arrive

To show results while the search is still running, read new results on each poll and remember the cursor.
Python
This works because results behave predictably:
  • Results are only ever added. A result’s position never changes, and results are never removed.
  • next_cursor is always returned. Even an empty page gives you a cursor, so you can continue from exactly where you stopped.
  • Every page includes search_status, so you do not need a separate status call to know when to stop.

Pagination reference

Treat a cursor as an opaque value: store it and send it back unchanged. Do not parse it, construct one yourself or do arithmetic on it. Only use a cursor with the search it came from. A malformed cursor returns 400 invalid_request. You can store a cursor and come back later. Reading from a stored cursor returns everything found since, which makes it easy to resume after a restart.

Polling intervals

  • Wait 2 seconds before the first poll, then a little longer each time, up to 10 seconds.
  • Polling counts toward your rate limit of 120 requests per minute per key. One search polled at this pace uses a small part of it.
  • If you receive a 429, wait the number of seconds given in the Retry-After header before trying again.

Webhooks

Coming Soon. A webhook is a URL on your server that Avina calls when something happens. Webhooks that tell you when a search has finished are not available yet. Until they are, poll the search’s status as shown above.

Common mistakes

Only stop when has_more is false and the search status is terminal. Otherwise you miss everything found after you caught up.
Without after, each call returns the first page again. Always pass the last next_cursor.
If your process gives up waiting, the search keeps running and spending. Call cancel to stop it.
A failed or cancelled search still has every result found before it stopped. Read them.