Spaces:
Sleeping
Sleeping
Ajit Panday
commited on
Commit
·
1b35bfe
1
Parent(s):
6565e69
Enhance API documentation with detailed request/response formats
Browse files
main.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from fastapi import FastAPI, File, UploadFile, HTTPException, Depends, Header, Form
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
from datetime import datetime
|
|
@@ -41,10 +41,93 @@ app = FastAPI(
|
|
| 41 |
* Customer access requires API key
|
| 42 |
|
| 43 |
## API Endpoints
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
*
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
""",
|
| 49 |
version="1.0.0"
|
| 50 |
)
|
|
|
|
| 1 |
+
from fastapi import FastAPI, File, UploadFile, HTTPException, Depends, Header, Form, status
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from fastapi.responses import JSONResponse
|
| 4 |
from datetime import datetime
|
|
|
|
| 41 |
* Customer access requires API key
|
| 42 |
|
| 43 |
## API Endpoints
|
| 44 |
+
|
| 45 |
+
### Call Processing
|
| 46 |
+
* POST /api/v1/process-call
|
| 47 |
+
- Process a voice call recording
|
| 48 |
+
- Requires: WAV file, caller number, called number
|
| 49 |
+
- Returns: Transcription, summary, sentiment analysis
|
| 50 |
+
|
| 51 |
+
### Call Management
|
| 52 |
+
* GET /api/v1/calls
|
| 53 |
+
- List all calls for a customer
|
| 54 |
+
- Optional filters: start_date, end_date
|
| 55 |
+
- Returns: List of call records
|
| 56 |
+
|
| 57 |
+
* GET /api/v1/calls/{call_id}
|
| 58 |
+
- Get specific call details
|
| 59 |
+
- Returns: Detailed call record
|
| 60 |
+
|
| 61 |
+
* GET /api/v1/calls/search
|
| 62 |
+
- Search calls with custom query
|
| 63 |
+
- Returns: Matching call records
|
| 64 |
+
|
| 65 |
+
### Admin Operations
|
| 66 |
+
* POST /api/v1/customers/
|
| 67 |
+
- Create new customer
|
| 68 |
+
- Requires: name, company_name, email
|
| 69 |
+
- Returns: Customer details with API key
|
| 70 |
+
|
| 71 |
+
* GET /api/v1/customers
|
| 72 |
+
- List all customers
|
| 73 |
+
- Returns: List of customer records
|
| 74 |
+
|
| 75 |
+
* GET /api/v1/customers/{customer_id}
|
| 76 |
+
- Get customer details
|
| 77 |
+
- Returns: Customer record
|
| 78 |
+
|
| 79 |
+
* DELETE /api/v1/customers/{customer_id}
|
| 80 |
+
- Delete customer
|
| 81 |
+
- Returns: Success message
|
| 82 |
+
|
| 83 |
+
### System
|
| 84 |
+
* GET /api/v1/health
|
| 85 |
+
- Health check endpoint
|
| 86 |
+
- Returns: System status
|
| 87 |
+
|
| 88 |
+
## Request/Response Formats
|
| 89 |
+
|
| 90 |
+
### Process Call
|
| 91 |
+
```json
|
| 92 |
+
POST /api/v1/process-call
|
| 93 |
+
Headers: {
|
| 94 |
+
"X-API-Key": "your-api-key"
|
| 95 |
+
}
|
| 96 |
+
Body: {
|
| 97 |
+
"file": <wav_file>,
|
| 98 |
+
"caller_number": "string",
|
| 99 |
+
"called_number": "string"
|
| 100 |
+
}
|
| 101 |
+
Response: {
|
| 102 |
+
"id": "uuid",
|
| 103 |
+
"transcription": "string",
|
| 104 |
+
"summary": "string",
|
| 105 |
+
"sentiment": "string",
|
| 106 |
+
"timestamp": "datetime"
|
| 107 |
+
}
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
### Create Customer
|
| 111 |
+
```json
|
| 112 |
+
POST /api/v1/customers/
|
| 113 |
+
Headers: {
|
| 114 |
+
"Authorization": "Bearer <admin_token>"
|
| 115 |
+
}
|
| 116 |
+
Body: {
|
| 117 |
+
"name": "string",
|
| 118 |
+
"company_name": "string",
|
| 119 |
+
"email": "string"
|
| 120 |
+
}
|
| 121 |
+
Response: {
|
| 122 |
+
"id": "integer",
|
| 123 |
+
"name": "string",
|
| 124 |
+
"company_name": "string",
|
| 125 |
+
"email": "string",
|
| 126 |
+
"api_key": "string",
|
| 127 |
+
"is_active": "boolean",
|
| 128 |
+
"created_at": "datetime",
|
| 129 |
+
"updated_at": "datetime"
|
| 130 |
+
}
|
| 131 |
""",
|
| 132 |
version="1.0.0"
|
| 133 |
)
|