
Handwriting OCR API Documentation
Integrate Pen to Print’s advanced handwriting recognition into your applications with a simple, REST-based handwriting to text API.
Overview
Pen to Print's API provides a simple way to add handwriting to text capabilities to your product. Your application sends a scanned handwritten page as a base64-encoded image, and our advanced handwriting OCR engine converts the content from image to text, returning clean, editable text in a structured JSON response.
Authentication is handled with a userId and API secret, making it straightforward to integrate into web, mobile, desktop, or backend services. The API is stateless and lightweight, ideal for powering handwriting to text features such as digitizing notes, processing scanned documents, or embedding handwriting OCR directly into your existing workflows.
Endpoint
Credentials
You can find both values in your Account Settings.
userIdsecretRequest Parameters
Send a JSON body with the following fields:
userIdsecretsrcImageExample JSON Body
{
"userId": "YOUR_USER_ID",
"secret": "YOUR_API_SECRET",
"srcImage": "BASE64_IMAGE_STRING"
}Response
On success (HTTP 200), the response is JSON:
{
"status": 1,
"value": "…recognized text…"
}Error Responses
{'error':'Missing parameters'}{'error':'Unauthorized'}{'error':'API access not allowed'}{'error':'Scan failed'}Code Examples
JavaScript (Node.js 18+)
import fs from "node:fs";
const endpoint = "https://api.pen-to-print.com/V1/notes";
const userId = "YOUR_USER_ID";
const secret = "YOUR_API_SECRET";
// Read an image file and convert to base64
const imageBase64 = fs.readFileSync("./image.jpg").toString("base64");
const res = await fetch(endpoint, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
userId,
secret,
srcImage: imageBase64,
}),
});
const data = await res.json().catch(() => ({}));
if (!res.ok) {
throw new Error(`Request failed: ${res.status}`);
}
console.log("Recognized text:", data.value);Python (requests)
import base64
import requests
endpoint = "https://api.pen-to-print.com/V1/notes"
user_id = "YOUR_USER_ID"
secret = "YOUR_API_SECRET"
with open("image.jpg", "rb") as f:
src_image = base64.b64encode(f.read()).decode("utf-8")
resp = requests.post(
endpoint,
json={
"userId": user_id,
"secret": secret,
"srcImage": src_image,
},
timeout=120,
)
resp.raise_for_status()
data = resp.json()
print(data.get("value", ""))cURL (macOS / Linux)
# 1. Export credentials
export P2P_USER_ID="YOUR_USER_ID"
export P2P_API_SECRET="YOUR_API_SECRET"
# 2. Convert image to base64
export IMG_B64="$(base64 < image.jpg | tr -d '\n')"
# 3. Call the endpoint
curl -sS -X POST "https://api.pen-to-print.com/V1/notes" \
-H "Content-Type: application/json" \
-d "{\"userId\":\"$P2P_USER_ID\",\"secret\":\"$P2P_API_SECRET\",\"srcImage\":\"$IMG_B64\"}" \
| cat


