πŸ“‘ API Reference - CommitBang/Snapfig-Frontend GitHub Wiki

API Reference

Base URL

  • http://:/api/v1

μ£Όμš” REST μ—”λ“œν¬μΈνŠΈ

λ©”μ„œλ“œ 경둜 μ„€λͺ…
POST /analyze PDF 파일 μ—…λ‘œλ“œΒ·λΆ„μ„
GET /documents λΆ„μ„λœ λ¬Έμ„œ λͺ©λ‘ 쑰회
GET /documents/{id} νŠΉμ • λ¬Έμ„œμ˜ 메타데이터 및 νŽ˜μ΄μ§€ 정보 쑰회
GET /documents/{id}/figures νŠΉμ • λ¬Έμ„œμ˜ Figure λͺ©λ‘ 쑰회
POST /auth/login API Key λ°œκΈ‰μš© 둜그인 (μ˜΅μ…˜)
POST /graphql GraphQL 쿼리 μ‹€ν–‰

GraphQL μ—”λ“œν¬μΈνŠΈ

  • URL: /graphql

  • μ˜ˆμ‹œ 쿼리:

    query GetDocument($id: ID!) {
      document(id: $id) {
        id
        metadata { title, author, pages }
        figures { figure_id, page_idx, confidence }
      }
    }
  • μ˜ˆμ‹œ 응닡:

    {
    "data": {
      "document": {
        "id": "123",
        "metadata": { "title": "Sample", "author": "Lee", "pages": 5 },
        "figures": [
          { "figure_id": "1", "page_idx": 0, "confidence": 0.92 }
        ]
       }
     }
    }

인증 방식

API Key:

  • λ°œκΈ‰: POST /auth/login (이메일/λΉ„λ°€λ²ˆν˜Έ) λ˜λŠ” 운영자 μˆ˜λ™ 등둝
  • 전솑: λͺ¨λ“  μš”μ²­ 헀더에 x-api-key: <your_api_key> 포함

μ˜ˆμ‹œ:

curl -H "x-api-key: YOUR_API_KEY" \
   -F "[email protected]" \
   http://localhost:5000/api/v1/analyze

μš”μ²­/응닡 μ˜ˆμ‹œ

PDF 뢄석 μš”μ²­

curl -X POST http://localhost:5000/api/v1/analyze \
-H "x-api-key: YOUR_API_KEY" \
-F "[email protected]"
  • 응닡 (200 OK)
    {
    "metadata": { "title": "Doc", "author": "Kim", "pages": 10 },
    "pages": [ /* ... */ ],
    "figures": [ /* ... */ ],
    "mapping_statistics": { "total_references": 12, "matched_references": 10, "match_rate": 0.83 }
    }

λ¬Έμ„œ λͺ©λ‘ 쑰회

curl http://localhost:5000/api/v1/documents \
-H "x-api-key: YOUR_API_KEY"
  • 응닡 (200 OK)
    [
    { "id": "123", "title": "Doc1", "created_at": "2025-06-01T12:00:00Z" },
    { "id": "124", "title": "Doc2", "created_at": "2025-06-02T09:30:00Z" }
    ]

πŸ“‹ 응닡 μ½”λ“œ

μ½”λ“œ μƒνƒœ μ„€λͺ…
200 βœ… 성곡 정상 처리 μ™„λ£Œ
400 ❌ μš”μ²­ 였λ₯˜ 파일 였λ₯˜, μš©λŸ‰ 초과 λ“±
500 πŸ”₯ μ„œλ²„ 였λ₯˜ 처리 μ‹€νŒ¨

⚠️ **GitHub.com Fallback** ⚠️