AffiliatePipe

Partner API / Google Sheets sync

Google Sheets sync

Every sale in a spreadsheet, refreshed each hour, with Apps Script and no server.

1. Add the script

In your sheet: Extensions, Apps Script. Paste this, then set AP_KEY under Project settings, Script properties.

function syncSales() {
  const key = PropertiesService.getScriptProperties().getProperty('AP_KEY');
  const res = UrlFetchApp.fetch('https://api.affiliatepipe.com/v1/conversions?limit=100', {
    headers: { Authorization: 'Bearer ' + key }
  });
  const rows = JSON.parse(res.getContentText()).data.map(c => [
    c.created_at, c.domain, c.amount / 100, c.commission / 100, c.status, c.approves_at
  ]);
  const sh = SpreadsheetApp.getActiveSheet();
  sh.clearContents();
  sh.appendRow(['Date (UTC)', 'Program', 'Sale', 'Commission', 'Status', 'Approves']);
  if (rows.length) sh.getRange(2, 1, rows.length, 6).setValues(rows);
}

2. Run it every hour

In Apps Script: Triggers, Add trigger, syncSales, time-driven, every hour. That is 24 calls a day.