9.9 KiB
9.9 KiB
🌐 Browser API Tester - Complete Guide
✨ What Is This?
A beautiful web-based tool to test your ChitFund API endpoints directly from the browser - no Postman needed!
🚀 Quick Start
Step 1: Access the Tester
Open your browser and go to:
https://chitfund.deepteklabs.com/test/api-tester.html
Or for local testing:
http://localhost:3000/test/api-tester.html
Step 2: Login
- Enter your manager mobile number
- Enter your password
- Click "Login"
You'll see:
- ✅ Success message with your name
- 🔐 Your authentication token displayed
- Token saved automatically for future use
Step 3: Test Endpoints
Click any of the pre-configured buttons:
- 📋 Get Review Queue - Transaction sync review queue
- 💳 Get UPI Settings - Your UPI configuration
- 📊 Get Sync Stats - Payment sync statistics
Or enter a custom endpoint!
📱 Screenshots
Login Screen:
╔═══════════════════════════════════════╗
║ 🔧 ChitFund API Tester ║
║ Test your API endpoints ║
╠═══════════════════════════════════════╣
║ ║
║ 🔐 Step 1: Login ║
║ ───────────────────────────────── ║
║ ║
║ Mobile Number: [9876543210 ] ║
║ Password: [•••••••••• ] ║
║ ║
║ [Login] ║
║ ║
║ Auth Token: ║
║ ┌─────────────────────────────────┐ ║
║ │ eyJhbGciOiJIUzI1NiIsInR5cCI6... │ ║
║ └─────────────────────────────────┘ ║
║ [Copy Token] ║
║ ║
╚═══════════════════════════════════════╝
API Testing:
╔═══════════════════════════════════════╗
║ 🚀 Step 2: Test API Endpoints ║
║ ───────────────────────────────── ║
║ ║
║ [📋 Get Review Queue] ║
║ [💳 Get UPI Settings] ║
║ [📊 Get Sync Stats] ║
║ ║
║ Custom Endpoint: ║
║ [/payments/phonepe/settings/upi] ║
║ [Call Custom Endpoint] ║
║ ║
║ [Clear Response] ║
╚═══════════════════════════════════════╝
Response Display:
╔═══════════════════════════════════════╗
║ 📦 Response ║
║ ───────────────────────────────── ║
║ { ║
║ "success": true, ║
║ "data": { ║
║ "upi_id": "9876543210@ybl", ║
║ "is_configured": true, ║
║ "transaction_fee": 0, ║
║ "transaction_fee_percentage": "0%"║
║ } ║
║ } ║
╚═══════════════════════════════════════╝
🎨 Features
1. Automatic Token Management
- ✅ Saves token to localStorage
- ✅ Persists across page refreshes
- ✅ Automatically includes in all requests
2. Pre-configured Endpoints
- Review Queue -
/transaction-sync/review-queue - UPI Settings -
/payments/phonepe/settings/upi - Sync Stats -
/transaction-sync/stats
3. Custom Endpoint Testing
- Enter any API endpoint
- Automatically adds base URL
- Uses saved authentication token
4. Beautiful UI
- 🎨 Modern gradient design
- 📱 Responsive layout
- 🌈 Color-coded responses
- ✨ Smooth animations
5. Response Formatting
- JSON syntax highlighting
- Scrollable response area
- Copy-friendly display
- Clear success/error indicators
🔧 How to Use
Testing Review Queue
- Login with manager credentials
- Click "Get Review Queue"
- See all transactions needing review
Response Example:
{
"success": true,
"data": {
"pending": [
{
"id": "123",
"amount": 10250,
"payer_vpa": "user@paytm",
"timestamp": "2025-11-10T10:00:00Z"
}
],
"total": 1
}
}
Testing UPI Settings
- Click "Get UPI Settings"
- See your UPI configuration
Response Example:
{
"success": true,
"data": {
"upi_id": "9876543210@ybl",
"is_configured": true,
"provider": "ybl",
"transaction_fee": 0,
"transaction_fee_percentage": "0%"
}
}
Testing Custom Endpoint
- Enter endpoint path (e.g.,
/payments/history) - Click "Call Custom Endpoint"
- View response
🛠️ Advanced Usage
Using Browser Console
The tool also exposes these functions in console:
// Login
login()
// Get review queue
getReviewQueue()
// Get UPI settings
getUPISettings()
// Call custom endpoint
callAPI('/your/endpoint', 'GET')
// Access saved token
console.log(window.authToken)
Copy Token for Other Tools
- Click "Copy Token" button
- Paste in Postman/cURL/other tools
Example cURL:
curl -X GET https://chitfund.deepteklabs.com/api/transaction-sync/review-queue \
-H "Authorization: Bearer PASTE_TOKEN_HERE"
📋 Pre-configured Endpoints
| Button | Endpoint | Description |
|---|---|---|
| 📋 Get Review Queue | /transaction-sync/review-queue |
Transactions needing review |
| 💳 Get UPI Settings | /payments/phonepe/settings/upi |
Your UPI configuration |
| 📊 Get Sync Stats | /transaction-sync/stats |
Payment sync statistics |
⚙️ Configuration
File Location
backend/public/api-tester.html
Access URL
https://chitfund.deepteklabs.com/test/api-tester.html
Backend Route
// In server.js
app.use('/test', express.static('public'));
🎯 Use Cases
1. API Development
- Test new endpoints
- Verify authentication
- Check response format
2. Debugging
- Reproduce issues
- Verify fixes
- Test error handling
3. Documentation
- Show API examples
- Demo to team
- Training new developers
4. Quick Testing
- No Postman needed
- No installation required
- Works on any device
🔐 Security Notes
Token Storage
- Stored in browser localStorage
- Persists across sessions
- Clear storage to logout
Manual Logout
To clear token:
// In browser console
localStorage.removeItem('authToken');
location.reload();
Or just close and reopen the page, then login with new credentials.
🐛 Troubleshooting
Issue: "Please login first"
Solution:
- Enter mobile number and password
- Click Login button
- Wait for success message
Issue: 401 Unauthorized
Solution:
- Token expired - login again
- Not a manager account - use manager credentials
- Wrong credentials - check mobile/password
Issue: Page not loading
Solution:
- Check backend is running
- Verify URL is correct
- Check browser console for errors
Issue: CORS Error
Solution: Backend already configured with:
app.use(cors({ origin: '*' }));
Should work. If not, restart backend.
🎨 Customization
Add New Endpoint Button
Edit api-tester.html:
<!-- In the button group -->
<button class="endpoint-btn" onclick="getMyNewEndpoint()">
🆕 My New Endpoint
</button>
// In the script section
async function getMyNewEndpoint() {
await callAPI('/my/new/endpoint', 'GET');
}
Change Colors
Edit the <style> section:
/* Change primary color */
background: linear-gradient(135deg, #YOUR_COLOR_1 0%, #YOUR_COLOR_2 100%);
📊 Status Indicators
Success (Green)
✅ Success! Status: 200
Error (Red)
❌ Error: Unauthorized (401)
Info (Blue)
ℹ️ Calling /api/endpoint...
🚀 Next Steps
Option 1: Use the Web Tester
- Open browser
- Go to
/test/api-tester.html - Login and test!
Option 2: Use Browser Console
- Open DevTools (F12)
- Use the JavaScript code examples above
- Test APIs directly
Option 3: Use Postman
- Copy token from web tester
- Import in Postman
- Add Authorization header
💡 Pro Tips
-
Keep Tab Open
- Token persists while tab is open
- No need to re-login frequently
-
Use Custom Endpoint
- Test any endpoint quickly
- Great for development
-
Copy Token
- Use in other tools
- Share with team (securely!)
-
Check Response
- Formatted JSON
- Easy to read
- Copy for documentation
📚 Related Documentation
- API Documentation:
backend/API_DOCUMENTATION.md - Authentication Guide: Check auth middleware
- Endpoint List: See routes files
🎉 Summary
Now you can:
- ✅ Test APIs from browser
- ✅ No Postman needed
- ✅ Beautiful UI
- ✅ Easy authentication
- ✅ Instant results
- ✅ Works anywhere
Access it now:
https://chitfund.deepteklabs.com/test/api-tester.html
Happy Testing! 🚀