ajinkya-mhetre-mern
Version:
A MERN starter with frontend and backend folders
743 lines • 23.3 kB
JSON
{
"info": {
"name": "Farm Produce Platform API",
"description": "Complete API collection for Farm Produce Platform with authentication, admin, farmer, and customer endpoints",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"variable": [
{
"key": "baseUrl",
"value": "http://localhost:5000/api",
"type": "string"
},
{
"key": "adminToken",
"value": "",
"type": "string"
},
{
"key": "farmerToken",
"value": "",
"type": "string"
},
{
"key": "customerToken",
"value": "",
"type": "string"
},
{
"key": "farmerId",
"value": "",
"type": "string"
},
{
"key": "productId",
"value": "",
"type": "string"
},
{
"key": "orderId",
"value": "",
"type": "string"
}
],
"item": [
{
"name": "Authentication",
"item": [
{
"name": "Register Admin",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 201) {",
" const response = pm.response.json();",
" pm.collectionVariables.set('adminToken', response.token);",
" pm.test('Admin registration successful', function () {",
" pm.expect(response.success).to.be.true;",
" pm.expect(response.user.role).to.eql('admin');",
" });",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"Admin User\",\n \"email\": \"admin@farmplatform.com\",\n \"password\": \"admin123\",\n \"phone\": \"+91-9876543210\",\n \"role\": \"admin\",\n \"address\": {\n \"street\": \"123 Admin Street\",\n \"city\": \"Mumbai\",\n \"state\": \"Maharashtra\",\n \"zipCode\": \"400001\"\n }\n}"
},
"url": {
"raw": "{{baseUrl}}/auth/register",
"host": ["{{baseUrl}}"],
"path": ["auth", "register"]
}
}
},
{
"name": "Register Farmer",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 201) {",
" const response = pm.response.json();",
" pm.collectionVariables.set('farmerToken', response.token);",
" pm.collectionVariables.set('farmerId', response.user.id);",
" pm.test('Farmer registration successful', function () {",
" pm.expect(response.success).to.be.true;",
" pm.expect(response.user.role).to.eql('farmer');",
" });",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"John Farmer\",\n \"email\": \"farmer@example.com\",\n \"password\": \"farmer123\",\n \"phone\": \"+91-9876543211\",\n \"role\": \"farmer\",\n \"address\": {\n \"street\": \"456 Farm Road\",\n \"city\": \"Pune\",\n \"state\": \"Maharashtra\",\n \"zipCode\": \"411001\"\n },\n \"farmDetails\": {\n \"farmName\": \"Green Valley Farm\",\n \"farmSize\": \"5 acres\",\n \"farmLocation\": \"Pune, Maharashtra\",\n \"certifications\": [\"Organic\", \"Non-GMO\"]\n }\n}"
},
"url": {
"raw": "{{baseUrl}}/auth/register",
"host": ["{{baseUrl}}"],
"path": ["auth", "register"]
}
}
},
{
"name": "Register Customer",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 201) {",
" const response = pm.response.json();",
" pm.collectionVariables.set('customerToken', response.token);",
" pm.test('Customer registration successful', function () {",
" pm.expect(response.success).to.be.true;",
" pm.expect(response.user.role).to.eql('customer');",
" });",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"Jane Customer\",\n \"email\": \"customer@example.com\",\n \"password\": \"customer123\",\n \"phone\": \"+91-9876543212\",\n \"role\": \"customer\",\n \"address\": {\n \"street\": \"789 Customer Lane\",\n \"city\": \"Mumbai\",\n \"state\": \"Maharashtra\",\n \"zipCode\": \"400002\"\n }\n}"
},
"url": {
"raw": "{{baseUrl}}/auth/register",
"host": ["{{baseUrl}}"],
"path": ["auth", "register"]
}
}
},
{
"name": "Login Admin",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 200) {",
" const response = pm.response.json();",
" pm.collectionVariables.set('adminToken', response.token);",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"admin@farmplatform.com\",\n \"password\": \"admin123\"\n}"
},
"url": {
"raw": "{{baseUrl}}/auth/login",
"host": ["{{baseUrl}}"],
"path": ["auth", "login"]
}
}
},
{
"name": "Login Farmer",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 200) {",
" const response = pm.response.json();",
" pm.collectionVariables.set('farmerToken', response.token);",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"farmer@example.com\",\n \"password\": \"farmer123\"\n}"
},
"url": {
"raw": "{{baseUrl}}/auth/login",
"host": ["{{baseUrl}}"],
"path": ["auth", "login"]
}
}
},
{
"name": "Login Customer",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 200) {",
" const response = pm.response.json();",
" pm.collectionVariables.set('customerToken', response.token);",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"customer@example.com\",\n \"password\": \"customer123\"\n}"
},
"url": {
"raw": "{{baseUrl}}/auth/login",
"host": ["{{baseUrl}}"],
"path": ["auth", "login"]
}
}
},
{
"name": "Get Profile (Admin)",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/auth/profile",
"host": ["{{baseUrl}}"],
"path": ["auth", "profile"]
}
}
}
]
},
{
"name": "Admin Operations",
"item": [
{
"name": "Get Dashboard Stats",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/admin/dashboard-stats",
"host": ["{{baseUrl}}"],
"path": ["admin", "dashboard-stats"]
}
}
},
{
"name": "Get Pending Farmers",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/admin/pending-farmers",
"host": ["{{baseUrl}}"],
"path": ["admin", "pending-farmers"]
}
}
},
{
"name": "Approve Farmer",
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"action\": \"approve\"\n}"
},
"url": {
"raw": "{{baseUrl}}/admin/verify-farmer/{{farmerId}}",
"host": ["{{baseUrl}}"],
"path": ["admin", "verify-farmer", "{{farmerId}}"]
}
}
},
{
"name": "Get All Users",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{adminToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/admin/users",
"host": ["{{baseUrl}}"],
"path": ["admin", "users"]
}
}
}
]
},
{
"name": "Farmer Operations",
"item": [
{
"name": "Get Farmer Dashboard Stats",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{farmerToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/farmer/dashboard-stats",
"host": ["{{baseUrl}}"],
"path": ["farmer", "dashboard-stats"]
}
}
},
{
"name": "Add Product (Text Only)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 201) {",
" const response = pm.response.json();",
" pm.collectionVariables.set('productId', response.product._id);",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{farmerToken}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"name\": \"Fresh Tomatoes\",\n \"description\": \"Organic red tomatoes freshly harvested from our farm\",\n \"category\": \"vegetable\",\n \"price\": 40,\n \"unit\": \"kg\",\n \"availableQuantity\": 100,\n \"harvestDate\": \"2025-06-15\",\n \"expiryDate\": \"2025-06-25\"\n}"
},
"url": {
"raw": "{{baseUrl}}/farmer/products",
"host": ["{{baseUrl}}"],
"path": ["farmer", "products"]
}
}
},
{
"name": "Add Product with Images",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 201) {",
" const response = pm.response.json();",
" pm.collectionVariables.set('productId', response.product._id);",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{farmerToken}}"
}
],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "name",
"value": "Fresh Apples",
"type": "text"
},
{
"key": "description",
"value": "Crispy red apples from Kashmir valley",
"type": "text"
},
{
"key": "category",
"value": "fruit",
"type": "text"
},
{
"key": "price",
"value": "120",
"type": "text"
},
{
"key": "unit",
"value": "kg",
"type": "text"
},
{
"key": "availableQuantity",
"value": "50",
"type": "text"
},
{
"key": "harvestDate",
"value": "2025-06-10",
"type": "text"
},
{
"key": "expiryDate",
"value": "2025-07-10",
"type": "text"
},
{
"key": "images",
"type": "file",
"src": []
}
]
},
"url": {
"raw": "{{baseUrl}}/farmer/products",
"host": ["{{baseUrl}}"],
"path": ["farmer", "products"]
}
}
},
{
"name": "Get My Products",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{farmerToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/farmer/products",
"host": ["{{baseUrl}}"],
"path": ["farmer", "products"]
}
}
},
{
"name": "Update Product",
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer {{farmerToken}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"price\": 45,\n \"availableQuantity\": 90,\n \"description\": \"Premium organic red tomatoes freshly harvested\"\n}"
},
"url": {
"raw": "{{baseUrl}}/farmer/products/{{productId}}",
"host": ["{{baseUrl}}"],
"path": ["farmer", "products", "{{productId}}"]
}
}
},
{
"name": "Get My Orders",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{farmerToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/farmer/orders",
"host": ["{{baseUrl}}"],
"path": ["farmer", "orders"]
}
}
},
{
"name": "Update Order Status",
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer {{farmerToken}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"status\": \"processing\",\n \"note\": \"Order is being prepared for dispatch\"\n}"
},
"url": {
"raw": "{{baseUrl}}/farmer/orders/{{orderId}}/status",
"host": ["{{baseUrl}}"],
"path": ["farmer", "orders", "{{orderId}}", "status"]
}
}
}
]
},
{
"name": "Customer Operations",
"item": [
{
"name": "Get All Products (Public)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/customer/products?page=1&limit=10&category=vegetable&search=tomato",
"host": ["{{baseUrl}}"],
"path": ["customer", "products"],
"query": [
{
"key": "page",
"value": "1"
},
{
"key": "limit",
"value": "10"
},
{
"key": "category",
"value": "vegetable"
},
{
"key": "search",
"value": "tomato"
}
]
}
}
},
{
"name": "Get Product Details (Public)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/customer/products/{{productId}}",
"host": ["{{baseUrl}}"],
"path": ["customer", "products", "{{productId}}"]
}
}
},
{
"name": "Place Order",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if (pm.response.code === 201) {",
" const response = pm.response.json();",
" pm.collectionVariables.set('orderId', response.order._id);",
"}"
]
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"items\": [\n {\n \"productId\": \"{{productId}}\",\n \"quantity\": 2\n }\n ],\n \"shippingAddress\": {\n \"street\": \"789 Customer Lane\",\n \"city\": \"Mumbai\",\n \"state\": \"Maharashtra\",\n \"zipCode\": \"400002\"\n }\n}"
},
"url": {
"raw": "{{baseUrl}}/customer/orders",
"host": ["{{baseUrl}}"],
"path": ["customer", "orders"]
}
}
},
{
"name": "Get My Orders",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/customer/orders",
"host": ["{{baseUrl}}"],
"path": ["customer", "orders"]
}
}
},
{
"name": "Get Order Details",
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/customer/orders/{{orderId}}",
"host": ["{{baseUrl}}"],
"path": ["customer", "orders", "{{orderId}}"]
}
}
},
{
"name": "Cancel Order",
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer {{customerToken}}"
}
],
"url": {
"raw": "{{baseUrl}}/customer/orders/{{orderId}}/cancel",
"host": ["{{baseUrl}}"],
"path": ["customer", "orders", "{{orderId}}", "cancel"]
}
}
}
]
},
{
"name": "Health Check",
"item": [
{
"name": "Health Check",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{baseUrl}}/health",
"host": ["{{baseUrl}}"],
"path": ["health"]
}
}
}
]
}
]
}