> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stophy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Bytes

> Get the exact bytes a site sent as a Base64 string, for files you want to save as they are. Read live on every call. $1 per 1,000 pages.

`rawBase64` returns the bytes the site sent, Base64 encoded. Use it when you need the file itself, not its text.

## Make a request

Get an API key in the [Quickstart](https://docs.stophy.dev/quickstart). This request returns the bytes of a small page.

```bash cURL theme={null}
curl -X POST https://api.stophy.dev/v1/scrape \
  -H "Authorization: Bearer $STOPHY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "formats": ["rawBase64"]
  }'
```

```typescript TypeScript theme={null}
const response = await fetch("https://api.stophy.dev/v1/scrape", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.STOPHY_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://example.com",
    formats: ["rawBase64"],
  }),
});
const { data } = await response.json();
console.log(data.metadata.contentType);
console.log(Buffer.from(data.rawBase64, "base64").toString("utf8"));
```

```python Python theme={null}
import base64
import os

import requests

response = requests.post(
    "https://api.stophy.dev/v1/scrape",
    headers={"Authorization": f"Bearer {os.environ['STOPHY_API_KEY']}"},
    json={
        "url": "https://example.com",
        "formats": ["rawBase64"],
    },
)
data = response.json()["data"]
print(data["metadata"]["contentType"])
print(base64.b64decode(data["rawBase64"]).decode("utf-8"))
```

## Read the response

`data.rawBase64` is a Base64 string without a `data:` prefix. `data.metadata.contentType` says what the bytes are. This real response is cut. The full string was 3,164 characters and decodes to the page's HTML, starting with `<!DOCTYPE html>`.

```json theme={null}
{
  "success": true,
  "data": {
    "rawBase64": "PCFET0NUWVBFIGh0bWw+PGh0bWwgbGFuZz0iZW4iPjxoZWFkPjxtZXRhIGNoYXJzZXQ9InV0Zi04Ij48…",
    "metadata": {
      "title": "Example Domain",
      "sourceURL": "https://example.com/",
      "url": "https://example.com/",
      "statusCode": 200,
      "contentType": "text/html",
      "cacheState": "miss",
      "scrapeId": "d836d60e-5fe4-4982-8328-f1b259c82ac2",
      "costUsd": 0.001
    }
  },
  "id": "d836d60e-5fe4-4982-8328-f1b259c82ac2",
  "costUsd": 0.001,
  "requestId": "d836d60e-5fe4-4982-8328-f1b259c82ac2"
}
```

## Options

| Field | Type | Default | Effect |
| - | - | - | - |
| `formats` | `array` | `["markdown"]` | Add `"rawBase64"` to return the bytes the site sent. |

## Limits and errors

* The page is always read live. Stophy never answers `rawBase64` from a stored copy, whatever `maxAge` says.
* A page that answers with a 404 or 410 status, or cannot be read, costs nothing.

## Price

\$1 per 1,000 pages. `rawBase64` adds nothing to the price of the page.

## Related

* [HTML](https://docs.stophy.dev/scrape/html.md) returns the cleaned page or the raw HTML as text.
* [PDFs and documents](https://docs.stophy.dev/scrape/pdfs-and-documents.md) reads PDFs, CSV and Excel files.
* [Freshness and caching](https://docs.stophy.dev/scrape/freshness-and-caching.md) explains stored copies.
* [Scrape overview](https://docs.stophy.dev/scrape/overview) lists every format.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.