---
title: "Read QR codes and barcodes from an image or a PDF"
method: POST
path: "/code-reader"
tags: ["Images"]
---

# Read QR codes and barcodes from an image or a PDF

`POST /code-reader`

## Request

- Base URL: `https://api.cofferdock.com`
- URL: `https://api.cofferdock.com/code-reader`
- Auth: API key in header `x-api-key`

Finds every QR code and barcode (Code128, Code39, EAN, UPC, ITF, DataMatrix, PDF417, Aztec and more) in an image or a PDF and returns what each one says. It is the counterpart of generate_qr and generate_barcode. Reading runs on our own servers (zxing, as WebAssembly): the file is not sent to any third party. Works on sharp, rotated, small or slightly noisy codes; a very blurry photo or a half-covered code can return an empty list, which still costs the credit. Images: JPEG, PNG, WebP, GIF, TIFF or AVIF (not SVG), up to 50 megapixels. PDF: up to 20 pages per call.

Costs 1 credit per call.

## Request body

- object
  - `file` string, byte, required: The image or PDF to read, base64-encoded. Images: JPEG, PNG, WebP, GIF, TIFF or AVIF (up to 50 megapixels, not SVG). PDF: up to 20 pages per call.
  - `formats` string[]: Only look for these code types: a list such as ["QRCode","Code128"] (case does not matter), or a group: "AllLinear" (1D barcodes), "AllMatrix" (QR, DataMatrix, PDF417, Aztec...), "AllRetail", "AllIndustrial". Default: every type it can read.
  - `max_codes` integer: Maximum number of codes to return, from 1 to 50. Default 20.
  - `pages` string: PDF only: which pages to read, 1-indexed, e.g. "1-3,5". Default: all pages (a PDF with more than 20 pages needs this).
  - `scale` number: PDF only: resolution at which each page is drawn before reading it, from 1 to 4. Default 2; higher = sharper and slower.

## Response `200`

Result.

- object
  - `success` boolean
  - `text` string, nullable: The content of the first code found, or null if there are none.
  - `codes` object[]: Every code found.
    - `format` string: The code type, e.g. QRCode, Code128, EAN13, DataMatrix.
    - `text` string: What the code says.
    - `content_type` string: Text, Binary, Mixed, GS1, ISO15434 or UnknownECI.
    - `bytes_base64` string: The raw bytes, only when the content is not plain text.
    - `page` integer: PDF only: the page the code is on (starting at 1).
  - `meta` object
    - `count` integer
    - `pages_scanned` integer
    - `pdf_pages` integer
    - `used` integer: Credits used this month, after this call.
    - `remaining` integer, nullable: Credits left this month (null = unlimited).
    - `unlimited` boolean

## Other responses

- `400`: Invalid input (nothing is charged).
- `401`: Missing or invalid API key.
- `403`: Email not verified.
- `429`: Monthly credit limit reached, or too many requests per minute for this key (see Retry-After).
- `503`: Server busy (queue full). Retry after the seconds in the Retry-After header.

---

[API](https://skmtc.dev/cofferdock/apis/cofferdock-api.md) · [All operations](https://skmtc.dev/cofferdock/apis/cofferdock-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cofferdock/apis/cofferdock-api/revisions/b57aa000d33a?raw)
