Your first scan in five minutes
One endpoint is enough: send a document photo, receive the cleaned, perspective-corrected image. This page walks you through it with cURL, Python and Node, then shows the browser SDK.
First, without an account
If you only want to see the output, open the demo, pick a sample photo and scan it. No signup, no key, and you can compare the result with the original photo.
Step 1: get an API key
- Create an account. Signup includes 50 free credits and needs no card.
- Open the dashboard and go to API keys.
- Create a key and copy it. The key is shown once, treat it like a password.
Step 2: first API call
POST one image as multipart form data to the crop endpoint. With binary=true, which is the default, the response body is the processed image itself, and -o writes it to a file.
curl -X POST "https://www.scankit.io/scan/crop" \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@document.jpg" \
-F "output_width=1536" \
-F "filter=white" \
-o scan.jpgThe same call in Python:
import requests
with open("document.jpg", "rb") as fh:
response = requests.post(
"https://www.scankit.io/scan/crop",
headers={"X-API-Key": "YOUR_API_KEY"},
files={"file": ("document.jpg", fh, "image/jpeg")},
data={"output_width": 1536, "filter": "white"},
timeout=60,
)
response.raise_for_status()
with open("scan.jpg", "wb") as out:
out.write(response.content)And in Node, without any SDK:
import fs from 'node:fs';
const body = new FormData();
body.append('file', new Blob([fs.readFileSync('document.jpg')]), 'document.jpg');
body.append('output_width', '1536');
body.append('filter', 'white');
const response = await fetch('https://www.scankit.io/scan/crop', {
method: 'POST',
headers: { 'X-API-Key': 'YOUR_API_KEY' },
body,
});
const scan = Buffer.from(await response.arrayBuffer());
fs.writeFileSync('scan.jpg', scan);What you get back is a clean, straight, tightly cropped image of the document, ready for OCR, AI extraction or your archive. Every call costs one credit, and a new account starts with fifty.
Step 3: the parameters you will actually use
| Parameter | Default | What it does |
|---|---|---|
| file or files | required | One image as file, several pages as files. |
| output_width | 1536 | Width of the returned image in pixels. |
| filter | white | white cleans the background, flat keeps the texture, original changes nothing. |
| version | 2 | Processing pipeline. 2 is the current one. |
| strip_black_border | true | Removes black borders around the detected page. |
| binary | true | true returns the image bytes, false wraps the result in JSON. |
| return_pdf | false | Returns a PDF instead of an image. |
| ocr_lang | eng | Language hint for text extraction. |
| output_width, segment_count | numbers | Anything non numeric is answered with 400 instead of a server error. |
Send several pages in one request with the files parameter, or call the endpoint once per page. Both are supported, the multi page path keeps the pages in one response.
Step 4: capture in the browser
If your own users should take the photo, load the SDK from our CDN and let it own the capture flow. The SDK is served from scankit.io, so there is nothing to build and nothing to publish.
<link rel="stylesheet" href="https://www.scankit.io/sdk/scankit-sdk.css" />
<div id="scan-area"></div>
<script src="https://www.scankit.io/sdk/scankit-sdk.min.js"></script>
<script>
const scanner = new ScanKit({
target: '#scan-area',
apiKey: 'YOUR_API_KEY',
onScanComplete: (result) => {
// result.image is the finished scan as a Blob
uploadToYourBackend(result.image);
},
});
scanner.init();
</script>The scanner calls your onScanComplete handler with the finished scan. A hosted scanner is the alternative when you cannot hold a key in the frontend at all: you create the scanner in the dashboard and send the link to whoever should scan.
What goes wrong when you install it
Five things bite most integrations at some point. Each line below is the behaviour as it is in the SDK today, so you do not have to discover it in production.
- The target has to exist before init(). If the element is not in the DOM yet, init() stops with ScanKit: Target element "#scan-area" not found. In React call it from useEffect, in Vue from onMounted, or use ScanKit.create(), which builds the element first.
- init() brings its own button. createButton is true by default and autoShow is false, so init() appends a "Start Scan" button into your target. buttonText renames it; createButton: false plus an explicit show() removes it when you want to start the scan yourself.
- The key is in the browser. apiEndpoint defaults to https://api.scankit.io and the browser sends the key, so any visitor can read it. Where that is not acceptable, use a hosted scanner or route the call through your own backend.
- onScanComplete hands over six fields, not one. image is a JPEG Blob from canvas.toBlob at quality 0.9; the other five describe what was done: filter, orientation, format, pages and timestamp.
- The scanner speaks two languages. Pass lang: "en" or lang: "de". Without it the scanner uses its own default.
| Field in onScanComplete | What it holds |
|---|---|
| image | the finished scan as a JPEG Blob, ready for URL.createObjectURL or FormData |
| filter | the filter that was applied: white, flat or original |
| orientation | the orientation that was applied to the page |
| format | the image format as a string, jpeg; the Blob itself is image/jpeg |
| pages | how many pages the scan produced |
| timestamp | when the scan finished |
<div id="scan-area"></div>
<script src="https://www.scankit.io/sdk/scankit-sdk.min.js"></script>
<script>
// The target has to be in the DOM at this point, otherwise init() stops.
const scanner = new ScanKit({
target: '#scan-area',
apiKey: 'YOUR_API_KEY',
lang: 'en',
buttonText: 'Scan document',
onScanComplete: ({ image, filter, format, pages }) => {
console.log('scan', format, pages, 'pages, filter', filter);
const form = new FormData();
form.append('file', image, 'scan.jpg');
fetch('/your-upload-endpoint', { method: 'POST', body: form });
},
});
scanner.init();
// Single page app? Let the framework own the lifecycle:
// useEffect(() => { const s = ScanKit.create({ target: '#scan-area', apiKey: KEY }); return () => s.destroy?.(); }, []);
</script>Tearing down: destroy() removes the button it created and the scanner UI it opened, so a component that unmounts leaves nothing behind. The SDK captures through a file input with the capture hint rather than a media stream, so there are no camera tracks for you to stop.
Credits, limits and errors
- One credit per processed page for crop, one credit per call for rectify and doc_axis_warp. A multi page request costs one credit per page it produced. Fifty free credits on signup.
- A thousand scan requests per hour and key. The request above that limit is refused with 429 and a Retry-After header.
- Authentication works with the X-API-Key header, an Authorization Bearer token, or an api_key query parameter. The header is the recommended one.
Typical error responses, in the order you will meet them:
| Status | Meaning | What to do |
|---|---|---|
| 401 | Missing API Key | Send the X-API-Key header. Check for a trailing space in the key. |
| 402 | Insufficient credits | Top up credits in the dashboard. No credits are consumed by a refused request. |
| 400 | Invalid parameter | output_width and segment_count must be integers. |
| 429 | Rate limit | Wait for the seconds given in Retry-After, then retry. No credits are consumed by a refused request. |
{
"errors": [
{ "title": "Missing API Key" }
]
}