---
title: "Waiting for a read"
description: "Hold the request while a read runs, then ask again until it’s ready or failed."
---

> Documentation Index
> Fetch the complete documentation index at: https://api.whyviral.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Waiting for a read

A post WhyViral has already read comes back at once. A new read takes longer, so send `wait` to have the request hold the answer, for up to 20 seconds.

If the read is still running when the wait ends, you get a 202 with `status: "pending"`. Ask for [`GET /reads/{id}`](https://api.whyviral.ai/api/reads/retrieve/) with `wait` until the status is `"ready"` or `"failed"`:

- `post` fills in once the post is fetched.
- `read` fills in once it’s ready.
- A read that runs too long fails as `TIMEOUT` and is refunded.

```json title="202 response"
{
  "id": "j57d3k9x2v8q1m4n6b0c5w7h2r9t3y8a",
  "object": "read",
  "status": "pending",
  "url": "https://www.tiktok.com/@example.kitchen/video/7430000000000000001",
  "finished_at": null,
  "error": null,
  "post": null,
  "read": null
}
```

The answer carries every field of [the read object](https://api.whyviral.ai/read-object/); this one is trimmed.

## In code

```js title="Node.js"
const base = "https://whyviral.ai/api/v1";
const headers = {
  Authorization: `Bearer ${process.env.WHYVIRAL_API_KEY}`,
  "Content-Type": "application/json",
};

async function call(path, init = {}) {
  const response = await fetch(base + path, { ...init, headers });
  const body = await response.json();
  if (!response.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
  return body;
}

let read = await call("/reads", {
  method: "POST",
  body: JSON.stringify({ url, wait: 20 }),
});
while (read.status === "pending") {
  read = await call(`/reads/${read.id}?wait=20`);
}
```

Sending the same link again with the same key returns the same read, free, so a retry after a dropped connection never pays twice.

Source: https://api.whyviral.ai/waiting/index.mdx
