RustProfit
← Back to site

Affiliate Program

Affiliate API

A read-only HTTP API for pulling your referred users' wagered and XP totals programmatically — no login required, just an API key. Separate from the affiliate dashboard, which is session-based and meant for a browser.

Authentication

Every request must include your affiliate API key as a header:

X-API-Key: <your api key>

Your key is issued when your affiliate code is created. If it's ever compromised, contact the site owner to have it rotated — the old key stops working immediately.

Missing or invalid key — every endpoint returns 401 Unauthorized:
{ "detail": "invalid API key" }

Get your referred users

GET /api/affiliate/users

Returns every user who signed up through your affiliate code, paginated 100 users per page, each with wagered amount and XP gained over four time windows: last 24 hours, last 7 days, last 30 days, and all time.

Query parameters

ParameterTypeDefaultDescription
pageinteger11-indexed page number.

Example request

# cents in the response — divide by 100 for dollars
curl -H "X-API-Key: <your api key>" \
  "https://rustprofit.com/api/affiliate/users?page=1"
# pip install requests
import requests

API_KEY  = "<your api key>"
BASE_URL = "https://rustprofit.com/api/affiliate/users"

def get_all_referred_users():
    users = []
    page = 1
    while True:
        resp = requests.get(BASE_URL, headers={"X-API-Key": API_KEY}, params={"page": page})
        resp.raise_for_status()
        data = resp.json()
        users.extend(data["users"])
        if page >= data["total_pages"]:
            break
        page += 1
    return users

for user in get_all_referred_users():
    print(user["steamid"], user["wagered"]["all_time"])
// Node 18+ or browser — fetch is built in
const API_KEY  = "<your api key>";
const BASE_URL = "https://rustprofit.com/api/affiliate/users";

async function getAllReferredUsers() {
  const users = [];
  let page = 1;
  while (true) {
    const res = await fetch(`${BASE_URL}?page=${page}`, { headers: { "X-API-Key": API_KEY } });
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    const data = await res.json();
    users.push(...data.users);
    if (page >= data.total_pages) break;
    page++;
  }
  return users;
}

const users = await getAllReferredUsers();
for (const user of users) {
  console.log(user.steamid, user.wagered.all_time);
}

Example response

{
  "affiliate_code": "summer2026",
  "page": 1,
  "per_page": 100,
  "total_users": 243,
  "total_pages": 3,
  "users": [
    {
      "steamid": "76561198000000000",
      "username": "SomePlayer",
      "joined_at": "2026-06-01T12:34:56.000000",
      "wagered":   { "24h": 500,  "7d": 4200,  "30d": 18300, "all_time": 92150 },
      "xp_gained": { "24h": 120,  "7d": 900,   "30d": 4100,  "all_time": 21000 }
    }
  ]
}

Response fields

FieldTypeDescription
affiliate_codestringYour affiliate's code, for convenience.
pageintegerThe page you requested.
per_pageintegerAlways 100.
total_usersintegerTotal number of users you've referred, across all pages.
total_pagesintegerTotal number of pages available.
usersarrayThe users on this page — see below.

Each entry in users:

FieldTypeDescription
steamidstringThe user's SteamID64.
usernamestring | nullTheir current display name.
joined_atstring (ISO 8601)When they linked your affiliate code.
wageredobjectTotal amount wagered, in cents, by time window.
xp_gainedobjectTotal XP earned, by time window.

wagered and xp_gained share the same shape:

{ "24h": 0, "7d": 0, "30d": 0, "all_time": 0 }

Pagination

Users are returned in a stable order (the order they signed up), so paging through with ?page=1, ?page=2, etc. never skips or repeats a user, even if new signups land in between requests.

Requesting a page beyond total_pages returns 400 Bad Request:

{ "detail": "page 3 is out of range — only 2 page(s) available" }

Rate limits

This endpoint is rate-limited per IP address. If you're polling on a schedule, every 5–10 minutes is more than sufficient — the underlying data doesn't change faster than that.