๐Ÿงช PathLab Bazaar โ€” Lab API

Integrate your lab system with our marketplace. Use these endpoints to manage your test catalog and orders programmatically.

Base URL: http://localhost:3000  |  Auth: JWT bearer token (use /api/auth/login or /api/auth/register first)  |  Content-Type: application/json
Quickstart:
  1. Register a provider account: POST /api/auth/register with role: "provider"
  2. Login: POST /api/auth/login โ†’ save the token
  3. Include Authorization: Bearer <token> header on every request
  4. List tests: GET /api/provider/tests

๐Ÿ” Authentication

POST/api/auth/register

Register a new provider account. Returns a JWT token and user object.

Body:
{
  "role": "provider",
  "name": "CityCare Diagnostics",
  "email": "admin@citycare.com",
  "phone": "+919876543210",
  "password": "your_password",
  "pincode": "110001",
  "address": "Connaught Place, New Delhi"
}
Response 200:
{
  "user": { "id": 2, "role": "provider", "name": "CityCare Diagnostics", "email": "admin@citycare.com", "client_id": null, "wallet_credits": 0, "commission_pct": 10 },
  "token": "eyJhbGciOiJIUzI1NiIs..."
}
POST/api/auth/login

Login with email and password. Returns a JWT token valid for 7 days.

curl -X POST http://localhost:3000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"demo@lab.com","password":"provider123"}'

๐Ÿงฌ Test Catalog

GET/api/tests

List all active tests. Supports filtering by query, category, and pincode. Public endpoint.

Query params: q category pincode
curl "http://localhost:3000/api/tests?pincode=110001&category=Biochemistry"
GET/api/provider/tests

List your own test catalog (active and inactive). Requires provider auth.

curl http://localhost:3000/api/provider/tests \
  -H "Authorization: Bearer <token>"
POST/api/provider/tests

Create a new test in your catalog.

Body:
{
  "name": "Complete Blood Count",
  "category": "Hematology",
  "description": "Measures RBC, WBC, platelets...",
  "mrp": 350,
  "offer_price": 250,
  "pincodes": "110001,110002,110003"
}
PUT/api/provider/tests/:id

Update an existing test. Send only the fields you want to change.

curl -X PUT http://localhost:3000/api/provider/tests/5 \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"offer_price": 199, "active": true}'
DELETE/api/provider/tests/:id

Permanently remove a test from your catalog.

POST/api/provider/tests/bulk-upload multipart/form-data

Upload a catalog in bulk via Excel (.xlsx). For labs without their own system.

Download a template: GET /api/provider/sample-catalog.xlsx
curl -X POST http://localhost:3000/api/provider/tests/bulk-upload \
  -H "Authorization: Bearer <token>" \
  -F "file=@catalog.xlsx"
Expected Excel columns:
ColumnRequiredExample
nameYesComplete Blood Count
categoryNoHematology
descriptionNoMeasures RBC, WBC...
mrpYes350
offer_priceNo250
pincodesNo110001,110002
Response: { added: 12, skipped: 0, total: 12 }

๐Ÿ“ฆ Orders

GET/api/provider/orders

List all orders for your lab. Use this for polling or as a backup to webhooks.

curl http://localhost:3000/api/provider/orders \
  -H "Authorization: Bearer <token>"
POST/api/provider/orders/:id/status

Update order status. Allowed values: placed, confirmed, sample_collected, processing, completed, cancelled.

curl -X POST http://localhost:3000/api/provider/orders/123/status \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"status":"sample_collected"}'
POST/api/provider/orders/:id/report multipart

Upload the final test report. Once uploaded, the customer gets notified and can download it.

curl -X POST http://localhost:3000/api/provider/orders/123/report \
  -H "Authorization: Bearer <token>" \
  -F "report=@cbc-report.pdf" \
  -F "notes=All values within normal range"

โญ Reviews

GET/api/tests/:id/reviews

Get all reviews and average rating for a test. Public endpoint.

curl http://localhost:3000/api/tests/5/reviews

๐Ÿ“… Scheduling

GET/api/provider/:id/slots

Get available appointment slots for a provider. Optional date=YYYY-MM-DD query.

POST/api/provider/slots

Bulk-add slots to your schedule. Send an array of {date, time, capacity}.

curl -X POST http://localhost:3000/api/provider/slots \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"slots":[
    {"date":"2026-06-20","time":"09:00","capacity":5},
    {"date":"2026-06-20","time":"10:00","capacity":5}
  ]}'

๐Ÿ”” Webhooks & Events

Coming soon: Configurable webhook URLs so your lab system can be notified instantly when an order is placed, status changes, or a report is uploaded. For now, poll GET /api/provider/orders every 60 seconds.

๐Ÿ“‹ Data Models

Order

{
  "id": 1,
  "order_code": "ORDMQD8OWBN193",
  "customer_id": 3,
  "provider_id": 2,
  "test_id": 1,
  "status": "placed|confirmed|sample_collected|processing|completed|cancelled",
  "amount": 250,
  "commission_pct": 10,
  "commission_amount": 23,
  "credits_used": 20,
  "credits_earned": 46,
  "scheduled_at": "2026-06-20 09:00:00",
  "address": "...",
  "pincode": "110001",
  "report_file": "report-ORDMQD8OWBN193.pdf",
  "created_at": "2026-06-14 03:43:29"
}

Test

{
  "id": 1,
  "provider_id": 2,
  "name": "Complete Blood Count (CBC)",
  "category": "Hematology",
  "description": "...",
  "mrp": 350,
  "offer_price": 250,
  "pincodes": "110001,110002,110003",
  "active": 1
}

โ“ Support

For integration help, email api@pathlab.com or open a ticket from your provider dashboard.