API Endpoint Documentation
1. Authentication (/api/auth
)
Method | Endpoint | Description | Example Body/Params |
---|---|---|---|
POST | /register | Register a new user. | { "username": "john", "email": "john@mail.com", "password": "pass123" } |
POST | /login | Login and receive JWT token. | { "username": "john", "password": "pass123" } |
POST | /forgot-password | Request password reset code via email. | { "emailOrUsername": "john" } |
POST | /reset-password | Reset password using code. | { "emailOrUsername": "john", "code": "123456", "newPassword": "newpass" } |
2. Puzzles (/api/puzzles
) (Community Marketplace: doesn't intregrate with frontend yet)
Method | Endpoint | Description | Example Body/Params |
---|---|---|---|
GET | /marketplace | List approved puzzles (with filters). | ?category=JS&difficulty=easy&page=1&limit=10 |
GET | /featured | List featured puzzles. | |
GET | /filters | Get available puzzle filters. | |
GET | /:id | Get puzzle by ID. | |
POST | / | Create a new puzzle (auth required). | { "title": "...", "question": "...", ... } |
GET | /user/puzzles | Get puzzles created by the user. | (auth required) |
PUT | /:id | Update a puzzle (auth required). | { "title": "..." } |
DELETE | /:id | Delete a puzzle (auth required). | |
POST | /:id/answer | Submit an answer to a puzzle. | { "answer": "B" } |
POST | /:id/review | Add a review to a puzzle. | { "rating": 5, "comment": "Great!" } |
POST | /:id/report | Report a puzzle. | { "reason": "Inappropriate" } |
GET | /user/stats | Get creator statistics (auth required). |
3. Leaderboard (/api/leaderboard
)
Method | Endpoint | Description | Example Body/Params |
---|---|---|---|
GET | /global | Get global leaderboard. | ?sortBy=totalPoints&limit=10&page=1 |
GET | /weekly | Get weekly leaderboard. | |
GET | /monthly | Get monthly leaderboard. | |
GET | /ranking/:username | Get ranking for a user. | |
POST | /challenge | Create a friend challenge (auth required). | { "challenged": "alice", ... } |
PUT | /challenge/:username/respond | Respond to a challenge (auth required). | { "accepted": true } |
GET | /challenges/:username | Get user's challenges (auth required). | |
GET | /notifications/:username | Get user notifications (auth required). | |
PUT | /notifications/:username/:notificationId/read | Mark notification as read (auth required). | |
PUT | /competition/:username/points | Update competition points (auth required). | { "points": 100 } |
4. Profile (/api/profile
)
Method | Endpoint | Description | Example Body/Params |
---|---|---|---|
POST | / | Create a user profile (auth required). | { "username": "john" } |
GET | /:username | Get profile by username. | |
PUT | /:username | Replace profile (admin only). | { "hintPoints": 10, ... } |
PATCH | /:username | Update profile fields. | { "hintPoints": 20 } |
PATCH | /:username/wrong-answer | Add a wrong answer to profile. | |
DELETE | /:username | Delete profile (admin only). | |
POST | /:username/daily-streak | Check and update daily streak. | |
GET | / | Get all profiles. |
5. Transactions (/api/transactions
)
Method | Endpoint | Description | Example Body/Params |
---|---|---|---|
POST | / | Create a transaction. | { "username": "john", "transactionId": "abc123", "selectedPackage": "pro" } |
GET | / | Get all transactions (admin only). | |
PUT | /:id | Update transaction by ID (admin only). | { "status": "approved" } |
PATCH | /:id | Update transaction by ID (admin only). | { "status": "faked" } |
GET | /user/:username | Get all transactions for a user. |
6. Chat (/api/chat
)
Method | Endpoint | Description | Example Body/Params |
---|---|---|---|
GET | /messages/:roomId | Get chat messages for a room. | ?page=1&limit=50 |
GET | /history/:userId | Get user's chat history (auth required). | ?page=1&limit=20 |
DELETE | /messages/:messageId | Delete a message (auth required). |
7. Levels (/api/levels
)
Method | Endpoint | Description | Example Body/Params |
---|---|---|---|
GET | / | Get all levels. | |
POST | / | Add a new level (admin only). | { "title": "...", ... } |
PUT | /:id | Update a level (admin only). | { "title": "..." } |
DELETE | /:id | Delete a level (admin only). |
8. Survey (/api/survey
)
Method | Endpoint | Description | Example Body/Params |
---|---|---|---|
POST | / | Submit a survey (auth required). | { "rating": 5, "happyIfClosed": true, "suggestion": "..." } |
GET | /summary | Get survey summary (public). | |
GET | /all | Get all survey responses (public). |