BitCheck Codex commited on
Commit
ff55461
·
1 Parent(s): 33d2258

docs: add IMAGE_API_INTEGRATION.md

Browse files
Files changed (1) hide show
  1. IMAGE_API_INTEGRATION.md +129 -0
IMAGE_API_INTEGRATION.md ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BitCheck Image Verification API Integration Guide
2
+
3
+ This document outlines the endpoints available in the BitCheck Image Verification API to help backend engineers integrate the image analysis features.
4
+
5
+ ## Base URL
6
+ The API is typically hosted at `http://localhost:8000` locally, or the appropriate production URL (e.g., your Hugging Face Space URL).
7
+
8
+ ---
9
+
10
+ ## Endpoints
11
+
12
+ ### 1. Verify Image
13
+ Analyze an uploaded image for AI generation, forensics, and metadata/provenance.
14
+
15
+ **Endpoint:** `POST /verify/image`
16
+
17
+ **Content-Type:** `multipart/form-data`
18
+
19
+ **Request Parameters (Form Data):**
20
+ - `file` **(Required)**: The image file to analyze (e.g., `.jpg`, `.png`, `.webp`).
21
+ - `user_email` *(Optional)*: Email address of the user who owns this image and report. Useful for retrieving reports later.
22
+ - `run_explainability` *(Optional, Default: true)*: Generate a Grad-CAM heatmap showing which parts of the image influenced the AI prediction.
23
+ - `run_ocr` *(Optional, Default: true)*: Run OCR to detect visible AI tool watermarks.
24
+ - `run_forensics` *(Optional, Default: true)*: Run lightweight forensic analysis (noise, blur, edge inconsistencies).
25
+ - `run_c2pa` *(Optional, Default: true)*: Analyze C2PA provenance data (Content Credentials).
26
+ - `threshold` *(Optional)*: Override the default confidence threshold for the classifier model.
27
+
28
+ **cURL Example:**
29
+ ```bash
30
+ curl -X POST "http://localhost:8000/verify/image" \
31
+ -H "accept: application/json" \
32
+ -H "Content-Type: multipart/form-data" \
33
+ -F "file=@/path/to/your/image.jpg" \
34
+ -F "user_email=user@example.com"
35
+ ```
36
+
37
+ **Success Response (200 OK):**
38
+ Returns a comprehensive `VerificationReport` JSON object containing:
39
+ - `verification_id`: A unique ID for this report.
40
+ - `status`: Verification status (`completed`, `error`).
41
+ - `trust`: The final trust score and classification (e.g., `real`, `ai_generated`).
42
+ - Sections for `input`, `filename_analysis`, `metadata`, `provenance`, `visible_watermark_ocr`, `visible_watermark_template`, `classifier`, `forensics`, and `explainability`.
43
+
44
+ ---
45
+
46
+ ### 2. Retrieve a Specific Report
47
+ Fetch a previously generated verification report by its ID.
48
+
49
+ **Endpoint:** `GET /reports/{verification_id}`
50
+
51
+ **Path Parameters:**
52
+ - `verification_id` **(Required)**: The unique ID returned from the `/verify/image` endpoint.
53
+
54
+ **cURL Example:**
55
+ ```bash
56
+ curl -X GET "http://localhost:8000/reports/b8f9e..." \
57
+ -H "accept: application/json"
58
+ ```
59
+
60
+ **Success Response (200 OK):**
61
+ Returns the same `VerificationReport` JSON object generated during the upload.
62
+
63
+ ---
64
+
65
+ ### 3. List Reports
66
+ Retrieve a list of past verification reports, optionally filtered by user email.
67
+
68
+ **Endpoint:** `GET /reports`
69
+
70
+ **Query Parameters:**
71
+ - `user_email` *(Optional)*: Filter the reports by the user's email address.
72
+
73
+ **cURL Example:**
74
+ ```bash
75
+ curl -X GET "http://localhost:8000/reports?user_email=user@example.com" \
76
+ -H "accept: application/json"
77
+ ```
78
+
79
+ **Success Response (200 OK):**
80
+ ```json
81
+ {
82
+ "count": 1,
83
+ "reports": [
84
+ {
85
+ "verification_id": "...",
86
+ "user_email": "user@example.com",
87
+ "filename": "image.jpg",
88
+ "status": "completed",
89
+ "trust": {
90
+ "final_decision": "real",
91
+ "trust_score_out_of_100": 95,
92
+ ...
93
+ },
94
+ "processing_time_ms": 1205.4
95
+ }
96
+ ]
97
+ }
98
+ ```
99
+
100
+ ---
101
+
102
+ ### 4. Health Check
103
+ Check if the API and its underlying services (OCR, C2PA, AI Models) are running correctly.
104
+
105
+ **Endpoint:** `GET /health`
106
+
107
+ **cURL Example:**
108
+ ```bash
109
+ curl -X GET "http://localhost:8000/health" \
110
+ -H "accept: application/json"
111
+ ```
112
+
113
+ **Success Response (200 OK):**
114
+ ```json
115
+ {
116
+ "status": "ok",
117
+ "service": "BitCheck Image Verification API",
118
+ "classifier_loaded": true,
119
+ "ocr_available": true,
120
+ "c2pa_available": true,
121
+ "device": "cpu"
122
+ }
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Static Assets (Explainability & Forensics)
128
+ If `run_explainability` or `run_forensics` are true, the JSON response will include URLs to generated images (e.g., heatmaps or annotated images). These are served via the static `/outputs/` directory.
129
+ Example: `http://localhost:8000/outputs/b8f9e..._gradcam_overlay.jpg`