What you are building
Your affiliates are often your own customers. Instead of sending them to Anderro, you can show their referral link, sales and earnings on a page in your app. Your server asks the Anderro API for one affiliate's numbers and renders them.
Server-side only
Call the API from your backend. A key in browser code can be read by anyone and gives access to every affiliate's data.
1. Create a read-only key
In Anderro, open Organization → API keys (or Settings → API keys in the account) and create a read-only key for the account. Read-only is enough for a dashboard. See Authentication.
2. Find your product id
curl https://anderro.com/api/v1/products \
-H "x-api-key: sk_acct_your_key"
Keep the id of the product whose program you are showing. Send it as X-Anderro-Product on the calls below.
3. Match your user to their affiliate
Store the affiliate's id (the partnership id) on your user record when they join. If you register affiliates through the API, POST /api/v1/affiliates returns it. Otherwise look it up once:
# By the referral code
curl "https://anderro.com/api/v1/affiliates?referral_code=jane-smith" \
-H "x-api-key: sk_acct_your_key" -H "X-Anderro-Product: your_product_id"
# By email, for affiliates you registered or imported yourself
curl "https://anderro.com/api/v1/[email protected]" \
-H "x-api-key: sk_acct_your_key" -H "X-Anderro-Product: your_product_id"
The email filter only finds affiliates whose address Anderro already shares with you. Affiliates who joined through the Anderro marketplace keep their address private until a payout is owed, so look those up by referral code.
4. Fetch their numbers
curl "https://anderro.com/api/v1/affiliates/part_abc123/stats?period=30d" \
-H "x-api-key: sk_acct_your_key" -H "X-Anderro-Product: your_product_id"
{
"data": {
"id": "part_abc123",
"referral_code": "jane-smith",
"period": "30d",
"clicks": 142,
"signups": 19,
"conversions": 8,
"revenue_cents": 196000,
"commissions_cents": 39200,
"conversion_rate": 5.63,
"previous_period": {
"clicks": 120,
"signups": 11,
"conversions": 5,
"revenue_cents": 122500,
"commissions_cents": 24500
}
}
}
Useful companions:
| Need | Endpoint |
|---|---|
| A chart of daily clicks, sales and commissions | GET /affiliates/{id}/stats/timeseries |
| All-time totals and pending/approved commission sums | GET /affiliates/{id} |
| Each sale and its commission | GET /commissions?affiliate_id= with the affiliate.id from the affiliate record |
| Program totals for a leaderboard or summary | GET /stats |
5. Cache
Organization and account keys allow 120 requests a minute. Cache each affiliate's response on your server for a minute or longer so page views do not turn into API calls.
Check the key
GET /api/v1/key returns what a key is and what it reaches: a quick way to confirm your configuration at start-up.