REST API v1

เอกสาร API ของ img2htm

เปลี่ยนรูปภาพเป็น HTML ระดับโปรดักชันด้วยการเรียก API ครั้งเดียว
API ของ img2htm รับไฟล์รูปภาพหรือ URL แล้วส่งคืน HTML, CSS, รูปภาพที่แยกแล้ว, JSON ที่มีโครงสร้าง และรายงานคุณภาพ

เริ่มต้นใช้งาน

API ของ img2htm รับไฟล์รูปภาพหรือ URL แล้วส่งคืน HTML, CSS, รูปภาพที่แยกแล้ว, JSON ที่มีโครงสร้าง และรายงานคุณภาพ การเรียกดูตัวอย่าง 50 ครั้งแรกของแต่ละเดือนฟรี

  1. สร้างบัญชีสร้างคีย์ในแดชบอร์ดของคุณ
  2. POST https://img2htm.com/api/v1/reconstruct with image_file, image_url or image_file_b64.
  3. Receive HTML, CSS, separated assets, structured JSON and a quality report in one response.

ผสานรวมได้ง่าย

มีตัวอย่างสำหรับ cURL, Node.js, Python, PHP, Ruby, Java, .NET และ Swift

HTML + CSS + JSON

เรียก API ครั้งเดียวได้ HTML, CSS, รูปภาพที่แยกแล้ว, JSON ที่มีโครงสร้าง และรายงานคุณภาพ

เครดิตคืออะไร?

1 เครดิตแปลงรูปภาพหนึ่งรูปที่มีความสูงไม่เกิน 15,000 px ได้ทั้งหมด รูปที่ยาวกว่าจะถูกนับเป็นหลายเครดิตโดยอัตโนมัติ ดูตัวอย่างฟรี

การยืนยันตัวตน

ส่งคีย์ API ของคุณในเฮดเดอร์ Authorization: Bearer หรือเฮดเดอร์ X-Api-Key

Authorization: Bearer i2h_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# or
X-Api-Key: i2h_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ตัวอย่างโค้ด

curl -X POST https://img2htm.com/api/v1/reconstruct \
  -H "Authorization: Bearer i2h_your_api_key" \
  -F "image_file=@product-page.jpg" \
  -F "mode=full" \
  -F "format=json"

รูปแบบผลลัพธ์

formatคำอธิบาย
jsonDefault. JSON object with html, css, content (structured sections + texts), assets (separated image URLs), quality and urls.
htmlReturns the reconstructed index.html document directly (text/html).
zipStreams a ZIP with index.html, styles.css, content.json, quality.json, sections/ and assets/.

การตอบกลับ

{
  "id": "3f9a1c2b7d4e6f80a1b2",
  "status": "done",
  "mode": "full",
  "credits_used": 2,
  "width": 860,
  "height": 24000,
  "sections": 16,
  "quality": {
    "text_accuracy": 97.4,
    "visual_fidelity": 94.1,
    "structure": 95.2,
    "sections": 16,
    "seconds": 41.8,
    "provider": "anthropic:claude-sonnet-5",
    "review": [],
    "auto_pass": true
  },
  "urls": {
    "html": "https://img2htm.com/api/v1/jobs/3f9a1c2b7d4e6f80a1b2/html",
    "zip": "https://img2htm.com/en/convert/3f9a1c2b7d4e6f80a1b2/download",
    "preview": "https://img2htm.com/en/convert/3f9a1c2b7d4e6f80a1b2/preview"
  },
  "assets": ["https://img2htm.com/files/results/3f9a1c2b7d4e6f80a1b2/assets/s01-a01.png"],
  "html": "<!DOCTYPE html> ...",
  "css": "/* img2htm base styles */ ...",
  "content": { "sections": [ ... ], "texts": [ ... ] }
}

อ้างอิง API

Reconstruct an image

POST/api/v1/reconstruct
พารามิเตอร์ประเภทคำอธิบาย
image_file จำเป็น*fileMultipart upload. JPG, PNG or WebP, up to 25 MB. *One of image_file, image_url, image_file_b64 is required.
image_urlstringPublic HTTP(S) URL of the image.
image_file_b64stringBase64-encoded image data.
mode ไม่บังคับfull | previewfull (default) converts the whole image and charges 1 credit per 15,000 vertical px. preview converts only the top 3,000 px for free.
lang ไม่บังคับstringOutput document language tag: ko, en, cn, tw, ja, mn, ru, th, id, vi, ar. Text is kept in its source language; this sets <html lang>/dir.
format ไม่บังคับjson | html | zipResponse format (see above).
async ไม่บังคับ1Return 202 Accepted immediately; poll GET /api/v1/jobs/{id} for the result.

Get a job

GET/api/v1/jobs/{id}

Returns the job object. Add ?include_html=1 to embed html, css and content.

Get the HTML document

GET/api/v1/jobs/{id}/html

Returns index.html as text/html.

Account

GET/api/v1/account
{ "email": "you@example.com", "credits": 38, "pixels_per_credit": 15000, "key": "i2h_ab12cd34…", "calls": 1207 }

ขีดจำกัดอัตราการเรียก

60 รูปต่อนาที per API key. When exceeded the API responds 429 Too Many Requests with a Retry-After: 60 header. Enterprise plans can raise this limit.

Exponential backoff

On 429 or 5xx, retry with exponential backoff: wait 1s, 2s, 4s, 8s … up to 5 attempts, adding random jitter. Never retry 4xx errors other than 429.

delay = min(60, (2 ** attempt) + random(0, 1))

รหัสข้อผิดพลาด

HTTPคำอธิบาย
400Missing image or unreadable URL.
401Missing, invalid or revoked API key.
402Insufficient credits. Response includes credits_needed and credits_available.
413File exceeds the upload limit.
415Unsupported image type.
429Rate limit exceeded.
500Conversion failed. Credits charged for the job are refunded automatically; error contains the reason.

ไลบรารีและเครื่องมือ

บันทึกการเปลี่ยนแปลง API

บันทึกการเปลี่ยนแปลง API

ทวงคืนเว็บที่ติดอยู่ในพิกเซล

รับเครดิตฟรีเมื่อสมัคร ไม่ต้องใช้บัตรเครดิต