Dhaniverse Game API Documentation

Version 1.0.0

Comprehensive API documentation for the Dhaniverse financial education game backend services.

Base URL: https://dhaniverse-backend.deno.dev

API Information

Base URL: https://dhaniverse-backend.deno.dev

Version: 1.0.0

Authentication: Bearer JWT tokens required for protected endpoints

Content Type: application/json

Health & Status

System health checks and status endpoints

GET /health

Check server health and database connection status

Parameters
Response Codes
200 — Server is healthy
{ "status": "ok", "timestamp": "2025-09-23T10:30:00.000Z", "database": "connected" }
GET /api/health

API-specific health check

Parameters
Response Codes
200 — API is healthy
{ "status": "ok", "message": "API is running", "version": "1.0.0" }
GET /api/game/status

Game service status

Parameters
Response Codes
200 — Game service status
{ "status": "ok", "service": "game-api", "timestamp": "2025-09-23T10:30:00.000Z" }

Authentication

User authentication and session management

POST /auth/send-magic-link

Send magic link authentication email

Parameters
email (string) REQUIRED — User's email address
Request Body Example
{ "email": "user@example.com" }
Response Codes
200 — Magic link sent successfully
{ "success": true, "message": "Magic link sent to your email" }
429 — Rate limit exceeded
{ "error": "Rate limit exceeded", "message": "Please wait before requesting another magic link" }
GET /auth/verify-magic-link

Verify magic link and authenticate user

Parameters
token (string) REQUIRED — Magic link verification token
Response Codes
200 — Authentication successful
{ "success": true, "user": { "email": "user@example.com", "id": "user_123" }, "token": "jwt_token_here" }
400 — Invalid or expired token
{ "error": "Invalid token", "message": "The magic link is invalid or has expired" }
GET /auth/me

Get current user information

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — User information
{ "id": "user_123", "email": "user@example.com", "username": "player1", "createdAt": "2025-09-23T10:30:00.000Z" }
401 — Unauthorized
{ "error": "Unauthorized", "message": "Invalid or missing authentication token" }
POST /auth/google

Authenticate with Google OAuth

Parameters
credential (string) REQUIRED — Google OAuth credential token
Request Body Example
{ "credential": "google_oauth_credential_token" }
Response Codes
200 — Google authentication successful
{ "success": true, "user": { "email": "user@gmail.com", "name": "John Doe", "picture": "https://example.com/avatar.jpg" }, "token": "jwt_token_here" }
POST /auth/internet-identity

Authenticate with Internet Identity

Parameters
principal (string) REQUIRED — Internet Identity principal
identity (object) REQUIRED — Identity verification data
Response Codes
200 — Internet Identity authentication successful
POST /auth/signout

Sign out current user

Response Codes
200 — Successfully signed out
{ "success": true, "message": "Successfully signed out" }

Player State

Manage player game state, progress, and currency

GET /game/player-state

Get current player state including currency and progress

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — Player state retrieved successfully
{ "id": "player_123", "username": "player1", "rupees": 1000, "bankBalance": 5000, "totalNetWorth": 6000, "level": 5, "experience": 2500, "lastLogin": "2025-09-23T10:30:00.000Z", "onboardingProgress": { "hasMetMaya": true, "hasFollowedMaya": true, "hasClaimedMoney": true, "hasBankAccount": true, "hasInvestedInStocks": false } }
PUT /game/player-state

Update player state

Headers
Authorization (string) REQUIRED — Bearer JWT token
Request Body Example
{ "level": 6, "experience": 3000, "onboardingProgress": { "hasInvestedInStocks": true } }
Response Codes
200 — Player state updated successfully
{ "success": true, "updatedState": { "level": 6, "experience": 3000 } }
PUT /game/player-state/rupees

Update player's rupee balance

Headers
Authorization (string) REQUIRED — Bearer JWT token
Request Body Example
{ "rupees": 1500, "reason": "Quest completion reward" }
Response Codes
200 — Rupee balance updated successfully
{ "success": true, "newBalance": 1500, "previousBalance": 1000 }
GET /game/player-state/starter-status

Check if player has claimed starter money

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — Starter status retrieved
{ "hasClaimed": false, "canClaim": true, "amount": 1000 }
POST /game/player-state/claim-starter

Claim starter money for new players

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — Starter money claimed successfully
{ "success": true, "amount": 1000, "newBalance": 1000 }
400 — Already claimed or ineligible
{ "error": "Already claimed", "message": "You have already claimed your starter money" }

Banking System

Virtual banking operations including accounts, deposits, and withdrawals

POST /game/bank-account/create

Create a new bank account for the player

Headers
Authorization (string) REQUIRED — Bearer JWT token
Request Body Example
{ "accountType": "savings", "initialDeposit": 500 }
Response Codes
200 — Bank account created successfully
{ "success": true, "account": { "id": "acc_123", "accountNumber": "DHAN123456789", "type": "savings", "balance": 500, "interestRate": 4.5, "createdAt": "2025-09-23T10:30:00.000Z" } }
GET /game/bank-account

Get player's bank account details

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — Bank account details retrieved
{ "id": "acc_123", "accountNumber": "DHAN123456789", "balance": 2500, "type": "savings", "interestRate": 4.5, "lastTransaction": "2025-09-23T09:15:00.000Z" }
POST /game/bank-account/deposit

Deposit money into bank account

Headers
Authorization (string) REQUIRED — Bearer JWT token
Request Body Example
{ "amount": 1000, "description": "Cash deposit" }
Response Codes
200 — Deposit successful
{ "success": true, "transaction": { "id": "txn_123", "amount": 1000, "type": "deposit", "balanceAfter": 3500, "timestamp": "2025-09-23T10:30:00.000Z" } }
POST /game/bank-account/withdraw

Withdraw money from bank account

Headers
Authorization (string) REQUIRED — Bearer JWT token
Request Body Example
{ "amount": 500, "description": "Cash withdrawal" }
Response Codes
200 — Withdrawal successful
{ "success": true, "transaction": { "id": "txn_124", "amount": 500, "type": "withdrawal", "balanceAfter": 3000, "timestamp": "2025-09-23T10:35:00.000Z" } }
400 — Insufficient funds
{ "error": "Insufficient funds", "message": "Account balance is insufficient for this withdrawal" }

Fixed Deposits

Fixed deposit investment management

GET /game/fixed-deposits

Get all player's fixed deposits

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — Fixed deposits retrieved
{ "deposits": [ { "id": "fd_123", "amount": 10000, "interestRate": 7.5, "tenure": 12, "maturityDate": "2026-09-23T10:30:00.000Z", "maturityAmount": 10750, "status": "active" } ] }
POST /game/fixed-deposits

Create a new fixed deposit

Headers
Authorization (string) REQUIRED — Bearer JWT token
Request Body Example
{ "amount": 5000, "tenure": 6, "interestRate": 6.5 }
Response Codes
200 — Fixed deposit created successfully
{ "success": true, "deposit": { "id": "fd_124", "amount": 5000, "interestRate": 6.5, "tenure": 6, "maturityDate": "2026-03-23T10:30:00.000Z", "maturityAmount": 5325 } }
POST /game/fixed-deposits/:id/claim

Claim matured fixed deposit

Parameters
id (string) REQUIRED — Fixed deposit ID
Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — Fixed deposit claimed successfully
{ "success": true, "amount": 10750, "interest": 750, "newBankBalance": 13750 }

Stock Trading

Stock portfolio management and trading operations

GET /game/stock-portfolio

Get player's stock portfolio

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — Stock portfolio retrieved
{ "portfolio": [ { "symbol": "RELIANCE", "shares": 10, "avgPrice": 2500, "currentPrice": 2650, "totalValue": 26500, "gainLoss": 1500, "gainLossPercent": 6 } ], "totalValue": 26500, "totalInvestment": 25000, "totalGainLoss": 1500 }
GET /game/stock-transactions

Get stock transaction history

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — Stock transactions retrieved
{ "transactions": [ { "id": "stock_txn_123", "symbol": "RELIANCE", "type": "buy", "shares": 10, "price": 2500, "total": 25000, "timestamp": "2025-09-20T10:30:00.000Z" } ] }
POST /game/stock-portfolio/buy

Buy stocks

Headers
Authorization (string) REQUIRED — Bearer JWT token
Request Body Example
{ "symbol": "TCS", "shares": 5, "price": 3200 }
Response Codes
200 — Stock purchase successful
{ "success": true, "transaction": { "symbol": "TCS", "shares": 5, "price": 3200, "total": 16000, "newBankBalance": 4000 } }
POST /game/stock-portfolio/sell

Sell stocks

Headers
Authorization (string) REQUIRED — Bearer JWT token
Request Body Example
{ "symbol": "TCS", "shares": 2, "price": 3300 }
Response Codes
200 — Stock sale successful
{ "success": true, "transaction": { "symbol": "TCS", "shares": 2, "price": 3300, "total": 6600, "newBankBalance": 10600, "gainLoss": 200 } }

Game Sync

Data synchronization and onboarding status

GET /game/sync

Sync all player data

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — All player data synchronized
{ "playerState": { "rupees": 1000, "bankBalance": 5000 }, "bankAccount": { "balance": 5000, "accountNumber": "DHAN123456789" }, "portfolio": { "totalValue": 26500 }, "fixedDeposits": { "active": 2, "totalAmount": 15000 } }
GET /game/bank-onboarding/status

Get bank onboarding progress status

Headers
Authorization (string) REQUIRED — Bearer JWT token
Response Codes
200 — Bank onboarding status
{ "hasAccount": true, "hasDeposited": true, "hasWithdrawn": false, "completionPercentage": 67 }

Admin Panel

Administrative endpoints for game management

GET /admin/summary

Get admin dashboard summary

Headers
Authorization (string) REQUIRED — Admin JWT token
Response Codes
200 — Admin summary data
{ "totalPlayers": 1250, "activePlayers": 89, "totalTransactions": 5643, "systemHealth": "good" }
GET /admin/active-players

Get list of currently active players

Response Codes
200 — Active players list
{ "players": [ { "username": "player1", "level": 5, "lastActivity": "2025-09-23T10:30:00.000Z" } ] }
POST /admin/ban

Ban a player

Request Body Example
{ "playerId": "player_123", "reason": "Violation of terms", "duration": "24h" }
Response Codes
200 — Player banned successfully
POST /admin/announce

Send announcement to all players

Request Body Example
{ "message": "Server maintenance in 30 minutes", "type": "warning" }
Response Codes
200 — Announcement sent successfully