POST/api/v1/edi-classify/classify

EDI 제약사 분류

처방·EDI 통계 이미지를 올리면 약품코드를 읽어 어느 제약사 약인지 자동으로 분류해 드립니다. 여러 제약사 약이 섞여 있어도 코드 기준으로 나눠 주고, 코드가 없는 문서는 약품명으로 후보 제약사를 추려 검수 시간을 줄여 줍니다. 자동 인식이라 문서 상태(사진 선명도·양식)에 따라 결과가 완벽하지 않을 수 있으니, 중요한 건은 확인을 권장합니다.

무료 1070원 / 이미지OpenAPI 스펙(JSON)

바로 실행

이 API 데모는 로그인 후 이용할 수 있습니다.

POST/api/v1/edi-classify/classify

처방·EDI 통계 이미지를 올리면 약품코드(9자리)를 읽어 제약사로 자동 분류합니다. 한 문서에 여러 제약사가 섞여 있어도 제약사별로 코드를 묶어 반환합니다. 코드가 인쇄되지 않은 문서는 약품명으로 후보 제약사를 추려 줍니다(검수용).

정확도 안내 — 자동 인식이라 100% 정확하지 않습니다. 화면 캡처처럼 선명할수록 정확하고, 흐릿한 사진·특수 양식은 놓칠 수 있습니다. 결과는 확정(코드 기반)후보(약품명 기반, 검수 권장)로 나눠 드리니, 중요한 건은 확인 후 사용하세요.

엔드포인트

POST https://marketapi.nadoo.ai/api/v1/edi-classify/classify

인증

헤더타입필수설명
x-api-keystring필수대시보드 발급 API 키 (pk_live_…)
Content-Typestring필수application/json
Idempotency-Keystring선택재시도 이중 과금 방지(권장 UUID). 같은 키+같은 이미지면 재처리 없이 최초 결과 반환, 같은 키로 다른 본문이면 422.

요청 본문 (JSON)

필드타입필수설명
imagestring택1base64 인코딩 이미지
imageUrlstring(uri)택1이미지 https URL (서버가 다운로드). 대용량은 presigned 업로드 권장(아래)
지원 형식JPG·PNG·WEBP. 그 외 형식·비-이미지 파일은 415 unsupported_media_type로 거절됩니다(과금 없음).
이미지 크기 — 요청 본문은 최대 25MB입니다. base64는 원본의 약 1.33배로 커지므로 image(base64)는 원본 ~18MB가 실질 한계이고, 초과 시 413 payload_too_large. 더 크거나 많은 이미지는 아래 대용량 업로드(presigned)imageUrl을 쓰면 용량 제한이 없습니다(이미지를 GCS로 직접 PUT).

응답 200 OK

필드타입설명
requestIdstring요청 식별자(Idempotency-Key 와 동일)
imageIdstring이미지 콘텐츠 해시(파일명 미사용)
docTypestringedi=약품 통계표. 아니면 non_edi(사업자등록증 등, 자동 반려·과금 제외)
manufacturersobject[]확정 — 약품코드로 조회된 제약사 목록
manufacturers[].namestring제약사명(업체명)
manufacturers[].codesstring[]해당 제약사로 확정된 9자리 약품코드
candidatesstring[]후보(선택) — 코드가 없을 때 약품명으로 추정한 제약사. 검수 권장. 없으면 생략
cost.krwnumber이번 호출 과금액(원). 무료·반려 시 0
cost.freeboolean무료 제공량으로 처리됐는지
balanceKrwnumber처리 후 잔액(원)

응답 예시

{
  "requestId": "3f9a1c2e-...",
  "imageId": "b6eef39918",
  "docType": "edi",
  "manufacturers": [
    { "name": "(유)한풍제약", "codes": ["658106350", "658106760"] },
    { "name": "(주)유한양행", "codes": ["642101080"] }
  ],
  "candidates": ["건일바이오팜(주)"],
  "cost": { "krw": 70, "free": false },
  "balanceKrw": 49950
}

비-EDI 문서는 { "docType": "non_edi", "rejected": true, "refunded": true, ... }로 반환되며 과금되지 않습니다.

에러 응답

HTTPerror의미
400no_imageimage(base64) 또는 imageUrl 누락
401invalid_keyAPI 키 누락/무효
402insufficient_credit무료 소진 + 잔액 부족
404product_not_found없는/종료된 API
413payload_too_large요청 본문 25MB 초과 → presigned 업로드 사용
415unsupported_media_type지원 형식(JPG·PNG·WEBP) 아님 → 과금 없음
502worker_error처리 실패(과금분 자동 환불)

예시 (cURL)

curl -X POST https://marketapi.nadoo.ai/api/v1/edi-classify/classify \
  -H "x-api-key: pk_live_xxxxxxxx" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"image":"<base64>"}'

배치 처리 (여러 장)

여러 이미지를 한 번에 처리합니다. 항목별로 독립 과금되며(성공 70원/건, 비-EDI·실패는 자동 환불), 부분 성공을 지원합니다. 각 이미지는 images(base64) 또는 imageUrls로 전달하며, 대량·대용량은 아래 presigned 업로드 + imageUrls를 권장합니다.

대용량 업로드 (presigned, 권장)

base64는 요청 크기 한계(본문 25MB·원본 ~18MB)가 있어, 대용량·대량은 presigned 업로드가 안정적입니다(용량 무제한 — 이미지를 GCS로 직접 PUT).① 업로드 URL 발급 → ② 이미지 PUT → ③ imageUrl 로 분류. (contentTypeimage/jpeg·png·webp만 허용, 그 외 415.)

# ① 업로드 URL 발급
curl -X POST https://marketapi.nadoo.ai/api/v1/uploads \
  -H "x-api-key: pk_live_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"contentType":"image/jpeg"}'
# → { "uploadUrl": "https://storage.googleapis.com/...(서명)", "imageUrl": "https://.../key", "expiresIn": 900 }

# ② 이미지를 uploadUrl 로 PUT (같은 Content-Type)
curl -X PUT "<uploadUrl>" -H "Content-Type: image/jpeg" --data-binary @처방전.jpg

# ③ imageUrl 로 분류(단건·배치 공통)
curl -X POST https://marketapi.nadoo.ai/api/v1/edi-classify/classify -H "x-api-key: pk_live_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"imageUrl":"<imageUrl>"}'
필드타입설명
uploadUrlstring이미지를 PUT 할 서명 URL(만료 시간 내)
imageUrlstring업로드 후 분류 요청의 imageUrl/imageUrls에 넣을 값
expiresInnumber서명 URL 유효 시간(초)

동기 POST /api/v1/edi-classify/classify-batch

이미지 배열을 즉시 처리해 전체 결과를 반환합니다(최대 30장). 본문 { images: base64[] } 또는 { imageUrls: string[] }.

응답 필드타입설명
total/done/ok/failednumber총·완료·성공·실패 건수
totalCostKrwnumber이번 배치 총 과금액(원). 비-EDI·실패분 제외
balanceKrwnumber처리 후 잔액(원)
results[]object[]항목별 결과(요청 순서, 아래 필드)
results[].indexnumber요청 배열 위치(0-based)
results[].statusstringok / failed
results[].docTypestringedi / non_edi
results[].manufacturers / candidatesobject[] / string[]단건과 동일(확정 제약사·후보)
results[].errorstring실패 시 사유
{
  "total": 3, "done": 3, "ok": 2, "failed": 0,
  "totalCostKrw": 140, "balanceKrw": 49900,
  "results": [
    { "index": 0, "status": "ok", "docType": "edi",
      "manufacturers": [{ "name": "(유)한풍제약", "codes": ["658106350"] }] },
    { "index": 1, "status": "ok", "docType": "non_edi" },
    { "index": 2, "status": "ok", "docType": "edi", "candidates": ["건일바이오팜(주)"] }
  ]
}

비동기 POST /api/v1/edi-classify/classify-batch-async

대량용(최대 500장). 접수 즉시 202로 작업 정보를 반환하고, 처리는 백그라운드(큐)에서 진행됩니다. 본문은 동기와 동일(images / imageUrls — 대량은 presigned imageUrls 권장).

202 응답 필드타입설명
jobIdstring작업 식별자(폴링에 사용)
statusstringqueued
totalnumber접수된 이미지 수
pollUrlstring진행/결과 폴링 경로

작업 폴링 GET /api/v1/jobs/{jobId}

작업 진행 상태·결과를 조회합니다(본인 소유만). status가 종료 상태가 될 때까지 폴링하세요.

status의미
queued접수됨, 처리 대기
processing처리 중(done/total로 진행률 확인)
done완료 — 전건 성공
partial완료 — 일부 실패(성공분만 과금)
failed완료 — 전건 실패

응답은 jobId·status·total·done·ok·failed·totalCostKrwresults[](동기 배치와 동일 스키마)를 포함합니다.

# ① 접수
curl -X POST https://marketapi.nadoo.ai/api/v1/edi-classify/classify-batch-async \
  -H "x-api-key: pk_live_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"imageUrls":["https://.../a.jpg","https://.../b.jpg"]}'
# → { "jobId": "job_abc", "status": "queued", "total": 2, "pollUrl": "/api/v1/jobs/job_abc" }

# ② 폴링(status 가 done/partial/failed 될 때까지 반복)
curl https://marketapi.nadoo.ai/api/v1/jobs/job_abc -H "x-api-key: pk_live_xxxxxxxx"
# → { "jobId": "job_abc", "status": "done", "total": 2, "done": 2, "ok": 2, "failed": 0,
#     "totalCostKrw": 140,
#     "results": [ { "index": 0, "status": "ok", "docType": "edi", "manufacturers": [...] }, ... ] }