請求和響應範例
使用這些範例來構建和調試您的整合
範例HTTP請求
POST https://{your-api-domain}/forgery_detection
請求標頭:
Authorization: Bearer {YOUR_API_TOKEN}
Content-Type: application/json; charset=UTF-8
Body:
{
"image": "<BASE64_IMAGE_WITHOUT_PREFIX>",
"return_heatmap": "false",
"detect_proportion": "false",
"restrict_probability": "0.8"
}範例響應
成功響應
當請求有效且影像處理成功時,API 會回傳 detection_result,用來判斷影像是竄改(fake)還是真實(real),並可選回傳竄改信心分數、熱力圖與位置座標。
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
"code": 0,
"data": {
"detection_result": "fake",
"tampered_proportion": 0.000587,
"heatmap": "<BASE64_HEATMAP_IMAGE>",
"tampered_location": [
{
"left": 100,
"top": 200,
"width": 150,
"height": 100,
"probability": 0.95
}
]
},
"message": "Success"
}業務錯誤響應
當上游服務報告業務錯誤時,API返回錯誤 = "API_ERROR"和非零代碼。您可以使用下面的錯誤代碼表映射此代碼。
HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=UTF-8
{
"error": "API_ERROR",
"code": 1004,
"message": "Image size error. Please ensure the image is less than 5MB and the longest side is less than 4000px."
}API 介紹
專門用於圖像偽造檢測的人工智慧技術透過使用ImgAuth.com API變得比以往任何時候都更容易。只需幾行程式碼,您就可以將此技術引入您的應用程式。
1
選擇 API 點數包
選擇適合你整合調用量的 API 點數方案
2
取得 API 存取權
購買後可在帳戶儀表板查看 API Key 與端點
3
使用程式碼範例
使用以下程式碼範例快速開始
4
正式上線
監控用量、調整請求參數並投入生產
身份驗證
使用帳戶中的 API 端點與 Bearer Token 進行驗證。購買 API 點數後,可在帳戶儀表板查看端點與權杖。請妥善保管權杖,不要提交到公開儲存庫。
API端點
POST https://{your-api-domain}/forgery_detection
請將 {your-api-domain} 替換為帳戶儀表板中顯示的 API 端點。
請求標頭
授權:
Bearer {YOUR_API_TOKEN}
請將 {YOUR_API_TOKEN} 替換為帳戶儀表板中顯示的 Bearer Token。請妥善保管,不要提交到公開儲存庫。
Content-Type:
application/json; charset=UTF-8
程式碼範例
使用我們的程式碼範例快速開始
#!/usr/bin/env bash
set -euo pipefail
API_DOMAIN="https://{your-api-domain}"
API_PATH="/forgery_detection"
API_TOKEN="{YOUR_API_TOKEN}"
IMAGE_FILE="${1:-testpaper.jpg}"
BASE64_IMAGE=$(base64 -i "$IMAGE_FILE" | tr -d '
')
read -r -d '' JSON_BODY <<EOF || true
{
"image": "$BASE64_IMAGE",
"return_heatmap": "false",
"detect_proportion": "false",
"restrict_probability": "0.8"
}
EOF
curl -X POST "${API_DOMAIN}${API_PATH}" \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "Content-Type: application/json; charset=UTF-8" \
-d "$JSON_BODY" \
-o response.json \
-s -w "\nHTTP status: %{http_code}\n"請求參數
使用這些參數配置您的API請求
| 參數 | 類型 | 描述 |
|---|---|---|
| image | string | Base64 編碼後的影像資料,需再進行 URL 編碼。最大 10 MB。最短邊至少 512 px,最長邊最多 8192 px。支援 jpg/jpeg/png/bmp。image 與 url 擇一提供。 |
| url | string | 完整圖片 URL,長度不超過 1024 位元組。編碼後圖片大小需控制在 10 MB 內。最短邊至少 512 px,最長邊最多 8192 px。支援 jpg/jpeg/png/bmp。image 與 url 擇一提供,並請關閉防盜鏈。 |
| return_heatmap | string | 是否回傳竄改熱力圖。預設 false。true 會回傳 Base64 熱力圖,false 不回傳。 |
| detect_proportion | string | 是否回傳竄改信心分數。預設 false。true 回傳信心分數,false 不回傳。 |
| restrict_probability | string | 回傳竄改座標的門檻值。範圍 0.1 到 1,支援 1 位小數,預設 0.8。只有當 probability 大於等於此門檻時才回傳 tampered_location。 |
回應參數
API 回應欄位說明
| 參數 | 類型 | 說明 |
|---|---|---|
| detection_result | string | 竄改檢測結果:"fake" 代表偵測到竄改,"real" 代表未偵測到竄改。 |
| tampered_proportion | float | 竄改信心分數,在 detect_proportion = true 時回傳。 |
| heatmap | string | 竄改區域的 Base64 熱力圖,在 return_heatmap = true 時回傳。 |
| tampered_location | array | 當 probability 大於等於 restrict_probability 時回傳可疑區域座標陣列。每個項目包含 left、top、width、height 與 probability。 |
| left | uint32 | 可疑區域左上角的水平座標。 |
| top | uint32 | 可疑區域左上角的垂直座標。 |
| width | uint32 | 可疑區域的寬度。 |
| height | uint32 | 可疑區域的高度。 |
| probability | float | 該可疑區域的信心分數。 |
錯誤代碼
API響應代碼參考
| 錯誤代碼 | 錯誤訊息 |
|---|---|
| 0 | success |
| 1000 | body error |
| 1001 | param error |
| 1002 | content type error |
| 1003 | image not exists |
| 1004 | image size error |
| 1005 | image format error |
| 1006 | invalid signature |
| 1007 | body size error |
| 1008 | no authorization |
| 2000 | server unknown error |
| 2001 | server timeout |
| 2003 | no content recognition |
| 2004 | validate data error |
| 3000 | remote server error |
| 4000 | base server error |
API message 保留上游原始回傳值,方便與你在正式環境中看到的回應保持一致。
API定價方案
相較一次性 credits 更優惠;訂閱方案仍然是長期高頻使用的最低成本選擇。
開發者
$99
500 點數
12 個月有效
適合評估與早期接入
- Bearer Token 驗證
- 回傳竄改結果、信心分數、熱力圖與區域座標
- 適用於文件與圖像竄改審核流程
- 購買後可在儀表板查看 API 端點與權杖
最受歡迎
成長
$359
2,000 點數
12 個月有效
適合生產試點與穩定調用
- Bearer Token 驗證
- 回傳竄改結果、信心分數、熱力圖與區域座標
- 適用於文件與圖像竄改審核流程
- 購買後可在儀表板查看 API 端點與權杖
規模
$899
5,000 點數
12 個月有效
適合批次流程與多專案團隊
- Bearer Token 驗證
- 回傳竄改結果、信心分數、熱力圖與區域座標
- 適用於文件與圖像竄改審核流程
- 購買後可在儀表板查看 API 端點與權杖
最佳價值
商業
$2,499
15,000 點數
12 個月有效
適合長期生產環境負載
- Bearer Token 驗證
- 回傳竄改結果、信心分數、熱力圖與區域座標
- 適用於文件與圖像竄改審核流程
- 購買後可在儀表板查看 API 端點與權杖