API Documentation
Complete guide to integrating FraudGuard's fraud detection API
Authentication
All API requests require authentication using an API token.
Obtaining an API Token
POST /api/auth/token
Content-Type: application/json
{
"username": "your_username",
"password": "your_password"
}
Response
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_at": "2025-11-02T12:00:00Z"
}
Using the Token
Include the token in the Authorization header:
Authorization: Bearer your_token_here
API Endpoints
1. Fraud Detection Check
Analyze content for fraud indicators
POST /api/fraud-check
Authorization: Bearer your_token
Content-Type: application/json
{
"data_type": "email|sms|phone",
"content": "Your content to analyze",
"metadata": {
"sender": "optional_sender_info",
"receiver": "optional_receiver_info"
}
}
Response
{
"status": "success",
"result": {
"is_fraud": false,
"confidence_score": 0.15,
"fraud_indicators": [],
"explanation": "Content appears legitimate",
"severity": "low"
},
"request_id": "req_123456"
}
2. Submit Transaction
Submit a transaction for fraud analysis
POST /api/transactions/submit
Authorization: Bearer your_token
Content-Type: application/json
{
"sender_id": "user123",
"receiver_id": "user456",
"amount": 150.00,
"description": "Payment for services"
}
Response
{
"status": "success",
"transaction_id": "txn_789",
"fraud_check": {
"requires_review": false,
"fraud_score": 0.12,
"status": "approved"
}
}
3. Get Fraud Detection Results
Retrieve results of a previous fraud check
GET /api/fraud-check/{request_id}
Authorization: Bearer your_token
Response
{
"status": "success",
"result": {
"request_id": "req_123456",
"timestamp": "2025-11-02T10:30:00Z",
"data_type": "email",
"is_fraud": true,
"confidence_score": 0.89,
"fraud_indicators": [
"Suspicious link detected",
"Urgency language present",
"Impersonation attempt"
]
}
}
4. Data Tokenization
Tokenize sensitive data for secure storage
POST /api/tokenize
Authorization: Bearer your_token
Content-Type: application/json
{
"data": "sensitive_information",
"type": "email|phone|custom"
}
Response
{
"status": "success",
"token": "tok_abc123def456",
"expires_at": "2025-11-09T10:30:00Z"
}
5. AI Financial Advisor Chatbot
Get personalized financial advice powered by AI. Accessible from the dashboard or via API.
POST /api/chat
Authorization: Required (User must be logged in)
Content-Type: application/json
{
"message": "How can I improve my credit score?",
"history": [
{
"role": "user",
"content": "Previous user message"
},
{
"role": "assistant",
"content": "Previous bot response"
}
]
}
Response
{
"success": true,
"response": "Improving your credit score takes time but is achievable! Here's how: 1. Pay Bills On Time: Payment history is the most important factor (35% of your score). 2. Keep Credit Utilization Low: Use less than 30% of your available credit...",
"youtube_video": {
"title": "How to Build Credit Score - Expert Tips",
"url": "https://www.youtube.com/watch?v=YBCT3HA4WTA",
"thumbnail": "https://i.ytimg.com/vi/YBCT3HA4WTA/maxresdefault.jpg"
}
}
Features:
- Context-Aware: Takes into account user's balance, transaction history, and spending patterns
- Voice-Enabled: Supports speech-to-text input and text-to-speech output
- YouTube Integration: Recommends relevant financial education videos
- Privacy-Focused: Does not store conversation history or sensitive financial data
- Real-Time: Powered by Gemini AI for instant, personalized responses
Limitations & Disclaimers:
- The AI provides general financial information only, not personalized investment advice
- Users should always consult certified financial advisors for major financial decisions
- The chatbot cannot guarantee investment returns or financial outcomes
- Advice is based on general financial principles and may not suit individual circumstances
- Not a substitute for professional tax, legal, or accounting advice
Topics the Chatbot Can Help With:
- Budgeting strategies
- Saving tips and emergency funds
- Credit score improvement
- Debt management strategies
- Basic investment principles
- Retirement planning basics
- Financial goal setting
- Spending pattern analysis
Error Handling
The API uses standard HTTP status codes:
- 200 OK - Request succeeded
- 400 Bad Request - Invalid parameters
- 401 Unauthorized - Invalid or missing token
- 429 Too Many Requests - Rate limit exceeded
- 500 Internal Server Error - Server error
Error Response Format
{
"status": "error",
"error": {
"code": "INVALID_TOKEN",
"message": "The provided API token is invalid or expired"
}
}
Usage Guidelines
Rate Limits
- Free tier: 100 requests/hour
- Pro tier: 1,000 requests/hour
- Enterprise: Unlimited
Best Practices
- Always validate input data before sending to the API
- Implement exponential backoff for retries
- Store API tokens securely (never in client-side code)
- Use webhooks for async processing of large batches
- Monitor your fraud score thresholds and adjust as needed
Data Types Supported
- Email - Full email content including headers
- SMS - Text message content
- Phone - Phone numbers with optional context
Code Examples
Python
import requests
API_URL = "https://api.fraudguard.com"
API_TOKEN = "your_token_here"
headers = {
"Authorization": f"Bearer {API_TOKEN}",
"Content-Type": "application/json"
}
data = {
"data_type": "email",
"content": "Your email content here"
}
response = requests.post(
f"{API_URL}/api/fraud-check",
headers=headers,
json=data
)
result = response.json()
print(f"Fraud detected: {result['result']['is_fraud']}")
print(f"Score: {result['result']['confidence_score']}")
JavaScript
const API_URL = 'https://api.fraudguard.com';
const API_TOKEN = 'your_token_here';
async function checkForFraud(content, dataType) {
const response = await fetch(`${API_URL}/api/fraud-check`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
data_type: dataType,
content: content
})
});
const result = await response.json();
console.log('Fraud detected:', result.result.is_fraud);
console.log('Score:', result.result.confidence_score);
return result;
}