Endpoints
a) The response includes detailed information about the user, such as their staking balance, staking rewards, and staking status.
b) Additional user-related endpoints could include updating user information, changing passwords, or retrieving transaction history.
Retrieve detailed information about a specific user.
URL: /users/{user_id}
Method: GET
Parameters:
user_id (required): The unique identifier of the user.
Response:
a) Along with the list of available staking pools, the response provides essential details such as the annual reward rate, minimum and maximum stake limits, current stake in the pool, and the status of each pool.
b) Future enhancements could include filtering staking pools based on criteria such as reward rate or stake limits.
Retrieve a list of available staking pools.
URL: /staking/pools
Method: GET
Response:
3. Stake Tokens
a) Users can stake their tokens in a specific staking pool by providing the user ID, pool ID, and the amount of tokens to stake.
b) The endpoint ensures that the staked tokens are deducted from the user's balance and added to the staking pool.
Stake tokens in a specific staking pool.
URL: /staking/stake
Method: POST
Parameters:
- user_id (required): The unique identifier of the user.
- pool_id (required): The unique identifier of the staking pool.
- amount (required): The amount of tokens to stake.
Response:
4. Claim Rewards
a) Users can claim their staking rewards by providing their user ID. The rewards are then added to the user's balance.
b) Additional features could include scheduling automatic reward claims or setting threshold limits for manual claims.
Claim staking rewards for a specific user.
URL: /staking/rewards/claim
Method: POST
Parameters: - user_id (required): The unique identifier of the user.
Response:
5. Withdraw Staked Tokens
a) Users can withdraw their staked tokens from a specific staking pool by providing their user ID, pool ID, and the amount of tokens to withdraw.
b) The endpoint verifies that the user has sufficient staked tokens in the pool and then transfers them back to the user's balance.
Withdraw staked tokens from a specific staking pool.
URL: /staking/withdraw
Method: POST
Parameters: - user_id (required): The unique identifier of the user. - pool_id (required): The unique identifier of the staking pool. - amount (required): The amount of tokens to withdraw.
Response:
6. Error Handling
If an error occurs, the API will return an appropriate HTTP status code along with a JSON response containing details about the error.
a) Standard Error Responses: The API provides standard error responses in JSON format, including details about the error type and any relevant error messages.
b) Error Code Consistency: Error codes are consistent across all endpoints for easier troubleshooting and debugging.
c) Rate Limiting: Implement rate limiting to prevent abuse of the API and ensure fair usage by all users.
Example error response:
Last updated