요청 방법
① 파일 그대로 보내기 — multipart/form-data (큰 PDF에 유리)
curl -X POST /api/v1/passport/read \
-F "file=@passport.pdf" \
-F "engine=rapidocr" \
-F "regions=all"
파일 경로 앞의 @가 빠지면 파일이 아니라 경로 문자열이 전송되어 415 UNSUPPORTED_MEDIA가 납니다.
② base64로 보내기 — application/json
curl -X POST /api/v1/passport/read \
-H "Content-Type: application/json" \
-d '{
"document": { "content_base64": "JVBERi0xLjQK...", "filename": "passport.pdf" },
"engine": "rapidocr",
"regions": "all",
"options": { "include_crops": false, "include_raw_lines": true }
}'
③ Python
import base64, requests
BASE = ""
# 엔진은 바뀔 수 있으니 먼저 목록을 확인
print(requests.get(f"{BASE}/api/v1/engines", timeout=10).json())
with open("passport.pdf", "rb") as f:
content = base64.b64encode(f.read()).decode("ascii")
resp = requests.post(
f"{BASE}/api/v1/passport/read",
json={
"document": {"content_base64": content, "filename": "passport.pdf"},
"engine": "rapidocr", # rapidocr | qwen3.6-35b | ppocrv6_gemma4
"regions": "all", # mrz | viz | all
},
timeout=180,
)
if resp.status_code == 200:
r = resp.json()
print(r["mrz"]["fields"]["document_number"], r["mrz"]["checksums"]["all_valid"])
print(r["viz"]["fields"] if r["viz"] else None)
else:
print(resp.status_code, resp.json()["error"])
지금 사용 가능한 엔진
(/api/v1/engines 실시간 조회)
불러오는 중...
응답 예시 (HTTP 200)
{
"request_id": "5f0c2d1e-…",
"engine": "rapidocr",
"regions": "all",
"document": { "filename": "passport.pdf", "pages": 5, "detected_page": 2 },
"detection": {
"detected": true, "backend": "hybrid",
"mrz_found": true, "viz_found": true, "viz_status": "estimated", "review_needed": false
},
"mrz": {
"success": true,
"lines": [
"P<LAODOUANGSOMPHOU<<PATTHANA<<<<<<<<<<<<<<<<",
"P3231839<6LAO9004148M3502103<<<<<<<<<<<<<<<0"
],
"fields": {
"format": "TD3 (Passport)", "document_type": "P",
"document_kind": { "kind": "passport", "name": "여권 (종류 표기 없음) / Passport", "note": "…" },
"issuing_country": "LAO", "issuing_country_name": "라오스 (Laos)",
"surname": "DOUANGSOMPHOU", "given_names": "PATTHANA", "full_name": "PATTHANA DOUANGSOMPHOU",
"name_possibly_truncated": false,
"document_number": "P3231839",
"nationality": "LAO", "nationality_name": "라오스 (Laos)",
"birth_date": "1990-04-14", "sex": "M", "expiry_date": "2035-02-10",
"personal_number": ""
},
"checksums": {
"document_number": true, "birth_date": true, "expiry_date": true,
"optional_data": null, "composite": true, "all_valid": true
},
"format_checks": {
"document_type": { "ok": true }, "issuing_country": { "ok": true }, "name": { "ok": true },
"nationality": { "ok": true }, "sex": { "ok": true }, "all_ok": true
},
"warnings": [],
"error": null
},
"viz": {
"success": true,
"fields": {
"surname": "DOUANGSOMPHOU", "given_names": "PATTHANA", "document_number": "P3231839",
"nationality": "LAO", "birth_date": "1990-04-14", "sex": "M",
"issue_date": "2025-02-11", "expiry_date": "2035-02-10", "place_of_birth": "VIENTIANE"
},
"lines": ["Passport No", "P 3231839", "…"],
"error": null
},
"timing_ms": { "detection": 2428, "engine": 3871, "model": 3100, "total": 6540 },
"history_id": 312
}