Last updated: 2025-01-31
A simple REST endpoint that receives a page image and returns layout sections detected on that page (bounding boxes, class, confidence). Ideal for e-paper / newspaper page processing, automated tagging and layout-aware rendering.
Overview
The AutoTag API analyzes a page image and returns an array of detected layout sections. Each detection contains the bounding box (xmin, ymin, xmax, ymax), a confidence score, a numeric class id, and a human-readable name (for example advertisement, headline, article, etc.).
Use cases:
- Automatic region extraction for e‑paper conversions
- Tagging ads vs editorial content
- Feeding region boxes to OCR engines selectively
Endpoint
POST https://myaccount.epaperpro.com/wp-json/autotag/v1/process
Content-Type: application/json
Request payload
{
"image_url": "https://epaper.roznamasahara.com/imgsrc/108439/1/1681-2469-2679-3134",
"license_key": "67f368baa1"
}
image_url(string) — publicly reachable URL of the page image (jpg/png/webp). The service fetches this URL to process the image.license_key(string) — your API license key for authentication/usage tracking.
Note: If your image URL requires a header or authentication, host the image on a publicly reachable URL (S3, CDN) or contact support for private ingestion options.
Example success response
{
"result": [
{
"xmin": 254.4713439941,
"ymin": 176.5631713867,
"xmax": 984.3304443359,
"ymax": 621.6746826172,
"confidence": 0.7537087798,
"class": 0,
"name": "advertisement"
}
]
}
Fields explained:
xmin,ymin,xmax,ymax— coordinates in pixels relative to the top-left of the image.confidence— floating number (0.0 to 1.0) showing model confidence for that detection.class— numeric id for detected label (internal mapping).name— human-readable class label.
Example usage
cURL
curl -X POST "https://myaccount.epaperpro.com/wp-json/autotag/v1/process" \
-H "Content-Type: application/json" \
-d '{
"image_url": "https://epaper.roznamasahara.com/imgsrc/108439/1/1681-2469-2679-3134",
"license_key": "67f368baa"
}'
JavaScript (Fetch)
async function autoTag(imageUrl, licenseKey) {
const res = await fetch('https://myaccount.epaperpro.com/wp-json/autotag/v1/process', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ image_url: imageUrl, license_key: licenseKey })
});
if (!res.ok) throw new Error('API error ' + res.status);
return res.json();
}
// usage
autoTag('https://epaper.roznamasahara.com/imgsrc/108439/1/1681-2469-2679-3134', '67f368ba1627')
.then(console.log)
.catch(console.error);
Python (requests)
import requests
url = 'https://myaccount.epaperpro.com/wp-json/autotag/v1/process'
payload = {
'image_url': 'https://epaper.roznamasahara.com/imgsrc/108439/1/1681-2469-2679-3134',
'license_key': '67f36a1627'
}
res = requests.post(url, json=payload)
res.raise_for_status()
print(res.json())
PHP (curl)
$ch = curl_init('https://myaccount.epaperpro.com/wp-json/autotag/v1/process');
$data = json_encode([
'image_url' => 'https://epaper.roznamasahara.com/imgsrc/108439/1/1681-2469-2679-3134',
'license_key' => '67f368b162'
]);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length: ' . strlen($data)
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Example page (HTML) — quick demo
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>AutoTag Demo</title>
<style>
body{font-family:system-ui,Arial;max-width:900px;margin:24px auto}
img{max-width:100%}
pre{background:#f6f8fa;padding:12px;border-radius:6px}
</style>
</head>
<body>
<h1>AutoTag API — Demo</h1>
<p>Paste an image URL and click <strong>Process</strong>.</p>
<input id="imageUrl" value="https://epaper.roznamasahara.com/imgsrc/108439/1/1681-2469-2679-3134" style="width:100%" />
<button id="go">Process</button>
<div id="out"></div>
<script>
document.getElementById('go').addEventListener('click', async () => {
const img = document.getElementById('imageUrl').value.trim();
const payload = { image_url: img, license_key: '67f368162' };
const res = await fetch('https://myaccount.epaperpro.com/wp-json/autotag/v1/process', {
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload)
});
const json = await res.json();
document.getElementById('out').innerHTML = '<h3>Result</h3><pre>'+JSON.stringify(json, null, 2)+'</pre>';
});
</script>
</body>
</html>
This page displays raw JSON — for production you would use the bounding boxes to draw overlays on the image and create clickable regions.
How to interpret coordinates and draw boxes
- Load the original image into an HTML
<img>element. - Get the rendered width/height and the original image natural width/height.
- The API returns pixel coordinates relative to the original image (natural width/height). If you render the image scaled, compute a scale factor and multiply the returned coordinates by that factor to draw accurate overlays.
Example (scale):
scaleX = renderedWidth / naturalWidth
scaleY = renderedHeight / naturalHeight
screenX = xmin * scaleX
screenY = ymin * scaleY
width = (xmax - xmin) * scaleX
height = (ymax - ymin) * scaleY
Error responses
400 Bad Request— malformed JSON or missing fields.401 Unauthorized— invalid or missinglicense_key.422 Unprocessable Entity— image URL not reachable or unsupported format.500 Internal Server Error— processing failure (retry with exponential backoff).
Always check the HTTP status code before parsing JSON.
Rate limiting & quotas
Your license key is subject to per-account quotas and rate limits. If you hit limits, you’ll receive HTTP 429 Too Many Requests with a Retry-After header. Contact support to increase quota.
Best practices
- Use CDN-hosted images for lower fetch latency.
- Cache results for identical
image_urlrequests to avoid re-processing the same image. - Filter detections by
confidence(e.g., only accept detections > 0.5). - If you need absolute layout precision, process images at their original resolution.
Security
- Keep
license_keysecret. Do not embed it in client-side code for production-facing applications. The demo above is for quick testing only. For production, call the AutoTag API from your server or implement a token exchange.
Changelog
- 2025-12-06 — Initial documentation created.
If you’d like, I can also add a ready-made client library snippet, an overlay visualizer (HTML + canvas) that draws boxes on the image, or convert this doc into a printable Markdown/HTML page.