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

# Generic OCR

> Run OCR on any image with the Dojah Generic OCR service and get back the raw text it contains, line by line.

<div className="dj-endpoint">
  <span className={`dj-method dj-method-post`}>POST</span>
  <code>/api/v1/ml/ocr/generic</code>
</div>

Run optical character recognition on any image and get back the raw text it contains, line by line — useful when you need the text off a document the structured endpoints don’t cover.

## Headers

| Header          | Required | Description                                         |
| --------------- | -------- | --------------------------------------------------- |
| `Authorization` | Yes      | Your app's secret key, sent as-is — *not* `Bearer`. |
| `AppId`         | Yes      | The App ID from your dashboard.                     |
| `Content-Type`  | Yes      | `application/json`                                  |

## Body parameters

| Parameter | Type   | Required | Description                                                                                          |
| --------- | ------ | -------- | ---------------------------------------------------------------------------------------------------- |
| `img`     | string | Yes      | Base64 value of the image. **Do not** include the data-type prefix (e.g. `data:image/jpeg;base64,`). |

## Response

A `200` returns `entity.data` — an array of the text fragments detected in the image, in reading order. The example below is trimmed; the live response returns every line.

## Errors

| Code  | Meaning                                                                                       |
| ----- | --------------------------------------------------------------------------------------------- |
| `400` | Bad request — a required field is missing or the image can't be read.                         |
| `401` | Unauthorized — check your key and `AppId` (no `Bearer` prefix).                               |
| `402` | Insufficient wallet balance. [Fund your wallet](/api-reference/core-concepts/wallet-billing). |
| `424` | Failed dependency — the analysis engine couldn't process the document.                        |
| `429` | Too many requests — back off and retry.                                                       |

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.dojah.io/api/v1/ml/ocr/generic" \
    -H "Authorization: {{secret_key}}" \
    -H "AppId: {{app_id}}" \
    -H "Content-Type: application/json" \
    -d '{
      "img": "/9j/4AAQSkZJRgABAQ…"
    }'
  ```

  ```js Node.js theme={null}
  const res = await fetch("https://api.dojah.io/api/v1/ml/ocr/generic", {
    method: "POST",
    headers: {
      Authorization: process.env.DOJAH_SECRET_KEY,
      AppId: process.env.DOJAH_APP_ID,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      img: "/9j/4AAQSkZJRgABAQ…"
    }),
  });
  const data = await res.json();
  ```

  ```python Python theme={null}
  import os, requests

  res = requests.post(
      "https://api.dojah.io/api/v1/ml/ocr/generic",
      headers={
          "Authorization": os.environ["DOJAH_SECRET_KEY"],
          "AppId": os.environ["DOJAH_APP_ID"],
      },
      json={
          "img": "/9j/4AAQSkZJRgABAQ…"
      },
  )
  data = res.json()
  ```
</RequestExample>

<ResponseExample>
  ```json POST /api/v1/ml/ocr/generic theme={null}
  {
    "entity": {
      "data": [
        "National Identity Management System",
        "Federal Republic of Nigeria",
        "National Identification Number Slip (NINS)",
        "Surname:",
        "John",
        "First Name:",
        "Doe",
        "NIN:",
        "70142123456",
        "Gender:",
        "M",
        "Issue Date:",
        "26/08/2014"
      ]
    }
  }
  ```
</ResponseExample>
