Endpoint: /wp-json/apicloud/v1/wallet/balance
Description
This API endpoint retrieves the balance of a user based on the provided Wallet key in the request’s authorization header. It uses the mycred plugin to fetch the balance of the user associated with the given Wallet key.
URL
POST /wp-json/apicloud/v1/wallet/balance
Methods
- POST: Retrieves the user’s balance based on the API key provided in the request header.
Headers
- Authorization: A Bearer token containing the Wallet Key, which is used to identify the user. The Wallet Key should be passed in the
Authorizationheader like so:Authorization: Bearer <WALLET_KEY>Where<WALLET_KEY>is the actual Wallet Key of the user.
Request Example
bashCopyPOST /wp-json/apicloud/v1/wallet/balance
Authorization: Bearer <API_KEY>
Response
The API will return a JSON object with the following structure:
jsonCopy{
"balance": 1000
}
Where:
- balance: The current balance of the user associated with the provided API key.
Error Responses
- API Key Not Found:
- Error Message:
User API key not found - HTTP Status: 404 Not Found
- This error occurs when the
Authorizationheader is missing or doesn’t contain a valid API key.
{ "error": "User API key not found" } - Error Message:
Permissions
- The permission callback is set to
__return_true, meaning it allows access to anyone with a valid API key in theAuthorizationheader.