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 Authorization header 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

  1. API Key Not Found:
    • Error Message: User API key not found
    • HTTP Status: 404 Not Found
    • This error occurs when the Authorization header is missing or doesn’t contain a valid API key.
    Example:jsonCopy{ "error": "User API key not found" }

Permissions

  • The permission callback is set to __return_true, meaning it allows access to anyone with a valid API key in the Authorization header.