AffiliatePipe

Partner API / A Discord stats bot

A Discord stats bot

Post yesterday's clicks, sales and commission to a channel every morning. About 20 lines, no libraries beyond requests.

1. Create a Discord webhook

In your channel: Edit channel, Integrations, Webhooks, New webhook. Copy its address into DISCORD_URL.

2. The script

import os, requests

API = "https://api.affiliatepipe.com/v1/stats?period=7d"
head = {"Authorization": "Bearer " + os.environ["AP_KEY"]}
s = requests.get(API, headers=head, timeout=10).json()

gbp = lambda m: f"${m['amount'] / 100:,.2f}"
lines = [f"**AffiliatePipe, last 7 days**",
         f"Clicks {s['clicks']:,}  (filtered {s['filtered']})",
         f"Sales {s['conversions']}",
         f"Pending {gbp(s['pending'])}, approved {gbp(s['approved'])}"]
for p in s["programs"]:
    lines.append(f"  {p['domain']}: {p['clicks']} clicks, {p['conversions']} sales")

requests.post(os.environ["DISCORD_URL"], json={"content": "\n".join(lines)}, timeout=10)

3. Run it every morning

0 8 * * * AP_KEY=ap_live_... DISCORD_URL=https://discord.com/api/reference/webhooks/... python3 /home/you/ap_discord.py
Cost One call a day. You could run it hourly and still use under 3% of your limit.