User API
Endpoints for accessing user-related data. All endpoints in this section require authentication.
GET/api/user/credits
Retrieve the current credit balance for the authenticated user.
Example Request
curl -X GET 'https://codingmantra.com/api/user/credits' \
-H 'Authorization: Bearer YOUR_API_KEY'
Example Response
{
"data": {
"credits": 50
}
}
GET/api/user/credits/history
Retrieve the last 100 credit transactions for the authenticated user, along with the current credit balance.
Example Request
curl -X GET 'https://codingmantra.com/api/user/credits/history' \
-H 'Authorization: Bearer YOUR_API_KEY'
Example Response
{
"data": {
"currentCredits": 40,
"history": [
{
"id": "some_transaction_id",
"type": "debit",
"tool": "Passport Photo Creator",
"creditsUsed": 10,
"timestamp": "2024-09-18T10:30:00.000Z"
},
{
"id": "welcome-bonus",
"type": "credit",
"source": "Welcome Bonus",
"creditsAdded": 50,
"timestamp": "2024-09-18T10:00:00.000Z"
}
]
}
}