# đ 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
1. **Enter your manager mobile number**
2. **Enter your password**
3. **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
1. **Login** with manager credentials
2. **Click** "Get Review Queue"
3. **See** all transactions needing review
**Response Example:**
```json
{
"success": true,
"data": {
"pending": [
{
"id": "123",
"amount": 10250,
"payer_vpa": "user@paytm",
"timestamp": "2025-11-10T10:00:00Z"
}
],
"total": 1
}
}
```
### Testing UPI Settings
1. **Click** "Get UPI Settings"
2. **See** your UPI configuration
**Response Example:**
```json
{
"success": true,
"data": {
"upi_id": "9876543210@ybl",
"is_configured": true,
"provider": "ybl",
"transaction_fee": 0,
"transaction_fee_percentage": "0%"
}
}
```
### Testing Custom Endpoint
1. **Enter** endpoint path (e.g., `/payments/history`)
2. **Click** "Call Custom Endpoint"
3. **View** response
---
## đ ī¸ Advanced Usage
### Using Browser Console
The tool also exposes these functions in console:
```javascript
// 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
1. **Click** "Copy Token" button
2. **Paste** in Postman/cURL/other tools
Example cURL:
```bash
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
```javascript
// 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:
```javascript
// 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:**
1. Enter mobile number and password
2. Click Login button
3. Wait for success message
### Issue: 401 Unauthorized
**Solution:**
1. Token expired - login again
2. Not a manager account - use manager credentials
3. Wrong credentials - check mobile/password
### Issue: Page not loading
**Solution:**
1. Check backend is running
2. Verify URL is correct
3. Check browser console for errors
### Issue: CORS Error
**Solution:**
Backend already configured with:
```javascript
app.use(cors({ origin: '*' }));
```
Should work. If not, restart backend.
---
## đ¨ Customization
### Add New Endpoint Button
Edit `api-tester.html`:
```html
```
```javascript
// In the script section
async function getMyNewEndpoint() {
await callAPI('/my/new/endpoint', 'GET');
}
```
### Change Colors
Edit the `