Herramientas

Apps Script para Google Sheets

Si lo único que necesitas es ver tus pedidos en una hoja de Google, esta es la ruta más corta. Pegas el script, le pones tu API key, y le das ejecutar.

Setup en 4 pasos

  1. Crea una hoja nueva en sheets.new.
  2. Menú Extensions → Apps Script. Borra el código que viene por defecto.
  3. Pega el script que está más abajo.
  4. Reemplaza SELLERP_API_KEY con tu clave (Settings → API en SELLERP).
  5. Click Run → fetchOrders. La primera vez Google te pide permisos — acéptalos.

Plantilla

Code.gsjs
/**
 * SELLERP → Google Sheets export.
 * Trae los últimos pedidos a la hoja activa.
 */
const SELLERP_API_KEY = "sellk_..."; // ⚠️ pega aquí tu clave
const SELLERP_BASE = "https://api.sellerp.com/v1";

function fetchOrders() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.clear();
  sheet.appendRow([
    "id", "marketplace", "status", "total", "currency",
    "buyer", "date_created", "date_closed"
  ]);

  let cursor = null;
  let total = 0;

  do {
    const url = SELLERP_BASE + "/orders?limit=100" + (cursor ? "&cursor=" + cursor : "");
    const res = UrlFetchApp.fetch(url, {
      headers: { Authorization: "Bearer " + SELLERP_API_KEY },
      muteHttpExceptions: true,
    });
    if (res.getResponseCode() !== 200) {
      throw new Error("SELLERP " + res.getResponseCode() + ": " + res.getContentText());
    }
    const body = JSON.parse(res.getContentText());

    for (const o of body.data) {
      sheet.appendRow([
        o.id, o.marketplace, o.status, o.total, o.currency,
        o.buyer_name || "", o.date_created, o.date_closed
      ]);
      total++;
    }
    cursor = body.pagination && body.pagination.next_cursor;
  } while (cursor);

  SpreadsheetApp.getActive().toast(total + " pedidos importados", "SELLERP");
}

/**
 * Trigger automático cada hora — ejecuta esto una sola vez para programarlo.
 */
function setupHourlyTrigger() {
  ScriptApp.getProjectTriggers().forEach(t => ScriptApp.deleteTrigger(t));
  ScriptApp.newTrigger("fetchOrders").timeBased().everyHours(1).create();
}

Próximamente: add-on oficial

Estamos trabajando en un Google Workspace add-on oficial: install desde el Marketplace de Google, login con SELLERP (sin manejar API keys), botón en la toolbar para refrescar. Hasta entonces, esta plantilla cubre el 95% de los casos.