File size: 3,442 Bytes
f7011cc ebe0f8b f7011cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# Test your FastAPI endpoints
GET http://127.0.0.1:8000/
Accept: application/json
### Authentication Endpoints
# Register a new user
POST http://127.0.0.1:8000/auth/register
Content-Type: application/json
{
"username": "testuser",
"email": "testuser@example.com",
"password": "securepassword",
"role": "admin"
}
### Login Endpoint Test
POST http://127.0.0.1:8000/auth/login
Content-Type: application/json
{
"email": "testuser@example.com",
"password": "securepassword"
}
### Farm Management Endpoints
# Create a new group (requires admin role, assuming a token is provided)
POST http://127.0.0.1:8000/groups/
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
{
"group_name": "Test Farm Group",
"farmers": [
"farmer_id_1",
"farmer_id_2"
],
"created_by": "admin_id"
}
### Get group by ID
GET http://127.0.0.1:8000/groups/{group_id}
Authorization: Bearer {{ACCESS_TOKEN}}
### Update a group
PUT http://127.0.0.1:8000/groups/{group_id}
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
{
"group_name": "Updated Farm Group"
}
### Delete a group
DELETE http://127.0.0.1:8000/groups/{group_id}
Authorization: Bearer {{ACCESS_TOKEN}}
### Health Records Endpoints
# Log a health record
POST http://127.0.0.1:8000/health/
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
{
"farm_id": "test_farm_id",
"disease_type": "Coccidiosis",
"treatment_given": "Anti-coccidial medication",
"logged_by": "admin_id"
}
### Get health records by farm ID
GET http://127.0.0.1:8000/health/test_farm_id
Authorization: Bearer {{ACCESS_TOKEN}}
### Task Management Endpoints
# Create a new task
POST http://127.0.0.1:8000/tasks/
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
{
"task_description": "Feed the chickens",
"assigned_to": "farmer_id",
"status": "pending",
"due_date": "2024-12-31T23:59:59Z"
}
### Get task by ID
GET http://127.0.0.1:8000/tasks/{task_id}
Authorization: Bearer {{ACCESS_TOKEN}}
# Update a task
PUT http://127.0.0.1:8000/tasks/{task_id}
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
{
"task_description": "Feed the chickens - updated",
"status": "in-progress"
}
### Delete a task
DELETE http://127.0.0.1:8000/tasks/{task_id}
Authorization: Bearer {{ACCESS_TOKEN}}
### Inventory Management Endpoints
# Add an inventory item
POST http://127.0.0.1:8000/inventory/
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
{
"item_name": "Chicken Feed",
"quantity": 100,
"status": "in-stock",
"updated_by": "admin_id"
}
### Get inventory item by ID
GET http://127.0.0.1:8000/inventory/{item_id}
Authorization: Bearer {{ACCESS_TOKEN}}
# Update an inventory item
PUT http://127.0.0.1:8000/inventory/{item_id}
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
{
"quantity": 150,
"status": "in-stock"
}
# Delete an inventory item
DELETE http://127.0.0.1:8000/inventory/{item_id}
Authorization: Bearer {{ACCESS_TOKEN}}
### Disease Detection Endpoint
# Predict disease from an uploaded image (replace image.png with actual test image path)
POST http://127.0.0.1:8000/disease_detection/predict_disease/
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: multipart/form-data
--boundary
Content-Disposition: form-data; name="file"; filename="image.png"
Content-Type: image/png
< ./path/to/your/image.png
--boundary--
|