hackrx / API_TESTING_GUIDE.md
Manjesh501's picture
Fi
598105d

πŸ§ͺ API Testing Guide - Using /docs Interface

πŸš€ Access Your API Documentation

Visit: https://Manjesh501-hackrx.hf.space/docs

You'll see the interactive Swagger UI documentation with all your API endpoints.

πŸ“‹ Step-by-Step Testing Guide

1. Basic Endpoints Testing

GET / (Root Endpoint)

  1. Find the endpoint: Look for GET / in the documentation
  2. Click "Try it out" button
  3. Click "Execute"
  4. Expected Response:
{
  "message": "HackRx 6.0 - Intelligent Query-Retrieval System",
  "version": "1.0.0",
  "status": "running",
  "endpoints": {
    "main": "api/v1/hackrx/run",
    "legacy": "hackrx/run",
    "detailed": "api/v1/hackrx/run/detailed",
    "health": "health",
    "docs": "docs",
    "test": "test"
  }
}

GET /health (Health Check)

  1. Find the endpoint: Look for GET /health
  2. Click "Try it out"
  3. Click "Execute"
  4. Expected Response:
{
  "status": "healthy",
  "message": "HackRx 6.0 is running",
  "services": {
    "query_service": true,
    "embedding_service": true,
    "llm_service": true,
    "pinecone_service": false
  }
}

GET /test (Test Endpoint)

  1. Find the endpoint: Look for GET /test
  2. Click "Try it out"
  3. Click "Execute"
  4. Expected Response:
{
  "message": "Test endpoint working!",
  "status": "success",
  "app_loaded": true,
  "mode": "app.py"
}

2. Main API Endpoints Testing

POST /api/v1/hackrx/run (Main Query Processing)

  1. Find the endpoint: Look for POST /api/v1/hackrx/run
  2. Click "Try it out"
  3. Fill in the request body:
{
  "documents": "https://example.com/document.pdf",
  "questions": [
    "What is the main topic of this document?",
    "What are the key points discussed?"
  ]
}
  1. Click "Execute"
  2. Expected Response: JSON with query results

POST /hackrx/run (Legacy Query Processing)

  1. Find the endpoint: Look for POST /hackrx/run
  2. Click "Try it out"
  3. Fill in the request body:
{
  "query": "What is the main topic of this document?",
  "document_url": "https://example.com/document.pdf"
}
  1. Click "Execute"
  2. Expected Response: JSON with query results

POST /api/v1/hackrx/run/detailed (Detailed Query Processing)

  1. Find the endpoint: Look for POST /api/v1/hackrx/run/detailed
  2. Click "Try it out"
  3. Fill in the request body:
{
  "documents": "https://example.com/document.pdf",
  "questions": [
    "What is the main topic of this document?",
    "What are the key points discussed?"
  ]
}
  1. Click "Execute"
  2. Expected Response: Detailed JSON with query results and metadata

POST /api/v1/analyze-document (Document Analysis)

  1. Find the endpoint: Look for POST /api/v1/analyze-document
  2. Click "Try it out"
  3. Fill in the request body:
{
  "document_url": "https://example.com/document.pdf"
}
  1. Click "Execute"
  2. Expected Response: Document analysis results

POST /api/v1/summarize-document (Document Summarization)

  1. Find the endpoint: Look for POST /api/v1/summarize-document
  2. Click "Try it out"
  3. Fill in the request body:
{
  "document_url": "https://example.com/document.pdf"
}
  1. Click "Execute"
  2. Expected Response: Document summary

🎯 What You'll See in /docs

Interface Elements:

  • Endpoint List: All available API endpoints
  • Try it out buttons: For interactive testing
  • Request/Response Schemas: Shows expected data formats
  • Execute buttons: Run the API calls
  • Response Section: Shows actual API responses
  • Status Codes: HTTP response codes (200, 400, 500, etc.)

Testing Workflow:

  1. Browse endpoints in the documentation
  2. Click "Try it out" for any endpoint
  3. Fill in required parameters (if any)
  4. Click "Execute" to run the API call
  5. Review the response in the results section
  6. Check status codes and response data

πŸ“Š Expected Results

Successful Responses:

  • Status Code: 200 OK
  • Response: JSON data with results
  • Headers: Proper content-type headers

Error Responses:

  • Status Code: 400, 404, 500, etc.
  • Response: Error message in JSON format
  • Example: {"error": "Invalid request format"}

πŸ” Testing Tips

For GET Endpoints:

  • No request body needed
  • Just click "Try it out" β†’ "Execute"

For POST Endpoints:

  • Fill in the request body with JSON
  • Use the example schemas provided
  • Make sure JSON is properly formatted

Common Test Data:

{
  "documents": "https://example.com/document.pdf",
  "questions": ["What is this document about?"]
}

Error Testing:

  • Try invalid JSON formats
  • Test with missing required fields
  • Use invalid URLs to test error handling

πŸš€ Quick Test Checklist

  • GET / - Returns app information
  • GET /health - Shows healthy status
  • GET /test - Returns test success message
  • POST /api/v1/hackrx/run - Processes queries
  • POST /hackrx/run - Legacy query processing
  • POST /api/v1/hackrx/run/detailed - Detailed processing
  • POST /api/v1/analyze-document - Document analysis
  • POST /api/v1/summarize-document - Document summarization

πŸŽ‰ Benefits of Using /docs

  1. Interactive Testing: No need for external tools
  2. Real-time Results: See responses immediately
  3. Schema Validation: Automatic format checking
  4. Error Handling: Clear error messages
  5. Documentation: Built-in API reference
  6. Easy Sharing: Share the /docs URL with others

Your API is now fully testable through the interactive documentation! πŸš€