API Documentation

Integrations

Reporting & Dashboards

Google Sheets

An Apps Script bound to a sheet, refreshing a leaderboard on a timer:

function refreshAffiliates() {
  const key   = PropertiesService.getScriptProperties().getProperty( 'WCUSAGE_KEY' );
  const url   = 'https://example.com/wp-json/wcusage/v2/reports/summary?top=50';
  const res   = UrlFetchApp.fetch( url, {
    headers: { Authorization: 'Bearer ' + key },
    muteHttpExceptions: true
  } );

  if ( res.getResponseCode() !== 200 ) {
    throw new Error( res.getContentText() );
  }

  const data  = JSON.parse( res.getContentText() );
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName( 'Affiliates' );

  sheet.clear();
  sheet.appendRow( [ 'Affiliate', 'Orders', 'Sales', 'Commission' ] );
  data.top_affiliates.forEach( function ( a ) {
    sheet.appendRow( [ a.user.display_name, a.orders_count, a.total_sales, a.total_commission ] );
  } );

  sheet.getRange( 'A1:D1' ).setFontWeight( 'bold' );
}

Add a time-driven trigger for refreshAffiliates and store the key under Project Settings → Script Properties, not in the code.

Looker Studio, Power BI, Metabase

All three can read a JSON/REST source with a bearer header. Point them at:

  • /reports/summary?top=50 for the program overview — one row of totals plus a leaderboard, already aggregated and cached for five minutes.
  • /affiliates?per_page=100 for a per-affiliate table, walking pages with X-WP-TotalPages.
  • /coupons/{id}/orders?from=&to= for transaction-level detail, one coupon at a time.
Tip
Refresh no more often than every five minutes. /reports/summary is cached for exactly that long, so a faster schedule returns identical data (cached: true) while still spending rate limit.

Warehousing the data

For an incremental ETL, drive it from /events rather than re-reading collections. Store the last event ID alongside your data, pull only what is new, and reconcile occasionally with a full pass over /affiliates. That keeps a nightly job to a handful of requests regardless of program size.