Endpoints
Referrals API
Manage referral codes for the UniDex platform
POST
/
api
/
referrals
Overview
The Referrals API allows users to check referral code information and claim new referral codes on the UniDex platform.
Request Body
Action to perform. Must be one of:
getCodeInfo
: Get information about a referral codeclaimCode
: Generate calldata to claim a referral code
The referral code to check or claim
Required for claimCode action. Ethereum address of the user claiming the code
Response Fields
For getCodeInfo action
The referral code
32-byte representation of the referral code
Address of the code owner, or “Code not claimed” if unclaimed
Whether the code has been claimed
For claimCode action
Encoded function call data for claiming the code
Address of the referral contract
The referral code being claimed
32-byte representation of the referral code
Example Usage
Check Code Information
Claim Code
Example Responses
For getCodeInfo
For unclaimed code
For claimCode
Error Responses
The endpoint will return appropriate error messages for:
- Missing action (
{"error": "Missing action"}
) - Missing code for getCodeInfo (
{"error": "Missing code"}
) - Missing code or userAddress for claimCode (
{"error": "Missing code or userAddress"}
) - Invalid userAddress (
{"error": "Invalid userAddress"}
) - Already claimed referral code (
{"error": "Referral code is already claimed"}
)
Body
application/json
Action to perform
Available options:
getCodeInfo
, claimCode
Referral code
Required for claimCode action