mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 12:07:11 +01:00
* fix(cat): meter Cat Credits from OpenRouter's real usage.cost Prefer OpenRouter's provider-reported per-request cost (usage.cost, USD→BTC) for Cat Credits debits, falling back to the registry token-price estimate when the field is absent. Ledger metadata now records pricingSource (provider_reported | registry_estimate). Free models always meter to 0. Pinned by regression tests for the metering preference and the OpenRouter cost plumbing (buffered + streamed), guarding the prior "$0 for unknown model" leak. Co-authored-by: Cursor <cursoragent@cursor.com> * chore(ai): refresh 2026 model roster and consolidate registry SSOT Update AI_MODEL_REGISTRY to the Q1-2026-verified roster and pricing (free, economy, standard, premium tiers), with boundary-safe resolution of provider-returned snapshot ids. model-registry.ts is now a generated projection of ai-models.ts rather than a drifted duplicate list. Refresh docs to match reality: rewrite MODEL_SYSTEM.md (provider chain, Cat Credits metering, current roster) and chat.md (authenticated /api/cat/chat contract), retiring references to the removed UnifiedAIClient/ModelStatusBadge and public /api/chat endpoint. Mark completed items in the research handoff. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
created_date, last_modified_date, last_modified_summary
| created_date | last_modified_date | last_modified_summary |
|---|---|---|
| 2025-06-05 | 2025-06-05 | Added documentation standards including creation and modification dates |
�� API Documentation
REST API Reference for OrangeCat
📋 Overview
OrangeCat provides a comprehensive REST API for managing Bitcoin fundraising projects, user profiles, and authentication. All API endpoints follow RESTful conventions and return JSON responses.
Base URL: /api/
Authentication: JWT tokens via Supabase Auth
Rate Limiting: Applied per endpoint
🔐 Authentication
All protected endpoints require authentication via JWT tokens:
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
📚 API Sections
🔐 Authentication Endpoints
- Authentication API - Login, register, password reset
👤 Profile Management
- Profile API - User profile CRUD operations
💰 Campaign Management
- Campaign API - Fundraising project operations
📁 File Upload
- Upload API - Avatar and banner image uploads
🤖 AI Chat
- Chat API - AI assistant integration using Google Gemini
🎯 Quick Start
1. Authentication
// Login
POST /api/auth/login
{
"email": "user@example.com",
"password": "password"
}
2. Get Profile
// Get current user profile
GET /api/profile
Authorization: Bearer {token}
3. Create Campaign
// Create new project
POST /api/projects
Authorization: Bearer {token}
{
"title": "My Campaign",
"description": "Campaign description",
"goal_amount": 1000000
}
📊 Response Format
Success Response
{
"success": true,
"data": { ... },
"message": "Operation successful"
}
Error Response
{
"success": false,
"error": "Error message",
"code": "ERROR_CODE"
}
🔒 Security
- Input Validation - All inputs validated and sanitized
- Rate Limiting - Protection against abuse
- CORS - Configured for secure cross-origin requests
- HTTPS Only - All API calls must use HTTPS in production
📈 Rate Limits
| Endpoint Type | Limit | Window |
|---|---|---|
| Authentication | 5 requests | 1 minute |
| Profile Updates | 10 requests | 1 minute |
| File Uploads | 3 requests | 1 minute |
| General API | 100 requests | 1 minute |
🐛 Error Codes
| Code | Description |
|---|---|
AUTH_REQUIRED |
Authentication required |
INVALID_TOKEN |
Invalid or expired token |
VALIDATION_ERROR |
Input validation failed |
RATE_LIMIT_EXCEEDED |
Too many requests |
RESOURCE_NOT_FOUND |
Resource not found |
PERMISSION_DENIED |
Insufficient permissions |
📚 Related Documentation
- Authentication System - Complete auth flow
- Security Guidelines - Security best practices
- Development Setup - Local API development