請求和響應範例
使用這些範例來構建和調試您的整合
範例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的方案
2
接收API郵件
購買後2小時內,您將收到一封包含您的專用API網域和AppCode的電子郵件。
3
使用程式碼範例
使用以下程式碼範例快速開始
4
調整參數
返回參數參考以調整請求
身份驗證
我們使用專用API網域和每個帳戶的Bearer令牌來驗證請求。購買API方案後,我們將向您發送包含您唯一API網域和令牌的電子郵件。出於安全原因,請不要發布您的API令牌。
API端點
POST https://{your-api-domain}/forgery_detection
將{your-api-domain}替換為購買後我們透過電子郵件發送給您的API網域。每個開發人員都有專用的網域和令牌。
請求標頭
授權:
Bearer {YOUR_API_TOKEN}
將{YOUR_API_TOKEN}替換為我們透過電子郵件發送給您的Bearer令牌。請保密,永遠不要將其提交到公共儲存庫。
Content-Type:
application/json; charset=UTF-8
程式碼範例
使用我們的程式碼範例快速開始
#!/usr/bin/env bash
set -euo pipefail
# Domain and token for the image processing proxy
API_DOMAIN="https://{your-api-domain}"
API_PATH="/forgery_detection"
API_TOKEN="{YOUR_API_TOKEN}"
# Image file passed as first argument (default: testpaper.jpg)
IMAGE_FILE="${1:-testpaper.jpg}"
if [ ! -f "$IMAGE_FILE" ]; then
echo "Image file not found: $IMAGE_FILE" >&2
echo "Usage: $0 path/to/image.jpg" >&2
exit 1
fi
echo "Encoding image to Base64: $IMAGE_FILE"
# Encode image to Base64 and remove newlines (use -i for BSD base64 on macOS)
BASE64_IMAGE=$(base64 -i "$IMAGE_FILE" | tr -d '
')
echo "Building JSON body..."
read -r -d '' JSON_BODY <<EOF || true
{
"image": "$BASE64_IMAGE",
"return_heatmap": "false",
"detect_proportion": "false",
"restrict_probability": "0.8"
}
EOF
echo "Calling proxy API..."
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"
echo "Response saved to response.json"請求參數
使用這些參數配置您的API請求
| 參數 | 類型 | 描述 |
|---|---|---|
| image | string | Base64編碼的圖片資料,需urlencode。大小不超過10MB。最短邊至少512px,最長邊最大8192px。支援jpg/jpeg/png/bmp格式。image和url二選一。 |
| url | string | 圖片完整URL,長度不超過1024位元組。圖片base64編碼後大小不超過10MB。最短邊至少512px,最長邊最大8192px。支援jpg/jpeg/png/bmp格式。image和url二選一。請注意關閉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 | 篡改區域熱力圖(當請求參數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 | Success |
| 1000 | body error | Request body error |
| 1001 | param error | Request parameter error |
| 1002 | content type error | Content-Type error |
| 1003 | image not exists | Image file not found |
| 1004 | image size error | Image size error |
| 1005 | image format error | Image format error |
| 1006 | invalid signature | Invalid signature |
| 1007 | body size error | Body size error |
| 1008 | no authorization | Authorization failed |
| 2000 | server unknown error | Server unknown error |
| 2001 | server timeout | Server timeout |
| 2003 | no content recognition | No content recognized |
| 2004 | validate data error | Validation data error |
| 3000 | remote server error | Remote server error |
| 4000 | base server error | Base server error |
API定價方案
以下方案專用於API
Starter
$99$0.198 / 積分
500積分
3個月有效期
- 支援大多數影像格式
- 文檔校正和增強
- 文檔偽造檢測
- 影像摩爾紋圖案去除
- 處理速度 ~2秒
最受歡迎
Popular
$349$0.07 / 積分
5,000積分
6個月有效期
- 支援大多數影像格式
- 文檔校正和增強
- 文檔偽造檢測
- 影像摩爾紋圖案去除
- 處理速度 ~2秒
Business
$749$0.05 / 積分
15,000積分
1年有效期
- 支援大多數影像格式
- 文檔校正和增強
- 文檔偽造檢測
- 影像摩爾紋圖案去除
- 處理速度 ~2秒
獨家
Enterprise
$1999$0.04 / 積分
50,000積分
1年有效期
- 支援大多數影像格式
- 文檔校正和增強
- 文檔偽造檢測
- 影像摩爾紋圖案去除
- 處理速度 ~2秒