PhotoCheck API in JavaScript (Node.js)
To check a photo for AI generation and faces in JavaScript (Node.js), POST it to https://photocheckapi.com/api/v1/analyze with your key as a Bearer token. The response is JSON with ai.score, faces.count and the file's metadata. The example below is complete and runs as it is.
1. Set your key
export PHOTOCHECK_API_KEY="pc_live_…"No key yet? Leave the header out: you get 5 keyless calls a day to try it. Credit packs start at $4.95.
2. Check a photo
import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("image", new Blob([await readFile("photo.jpg")]), "photo.jpg");
const res = await fetch("https://photocheckapi.com/api/v1/analyze", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.PHOTOCHECK_API_KEY}` },
body: form,
});
if (res.status === 402) throw new Error("Out of credits");
if (res.status === 429) {
const wait = Number(res.headers.get("retry-after") ?? 1);
throw new Error(`Rate limited, retry in ${wait}s`);
}
const result = await res.json();
console.log(result.summary.text);
console.log("AI score:", result.ai.score, "faces:", result.faces.count);Notes
- Node 18+ has fetch, FormData and Blob built in; no package needed.
- Call the API from your server. A key in browser code can be read and spent by anyone.
- Swap
/analyzefor/faces,/ai-detector/metadatato run one check. Each costs the same one credit. - Branch on
error.typerather than the HTTP status alone; the full list is in the error reference.