Winter Gifts. A gift box is waiting in every Data API account until 31 December. Open your gift

Card prices in Google Sheets: a collection spreadsheet that updates itself

One Apps Script file: a menu item that reprices every card in the sheet in bulk, and a function that finds a card id by name and number.

What do you get?

A Google Sheet with one card per row and a Flipzi → Refresh prices menu. Running it fills in the current price, the market it came from and when it was observed, for every row, using the bulk endpoint of the Flipzi Data API. A second function finds the id of a card from its name and number, so the sheet can be filled without leaving it.

You need a Google account and a Data API key. Create a free developer account to get one.

1. Lay out the sheet

Row 1 holds headers; data starts in row 2. The script reads column A and writes columns B to D. Everything from column E on is yours.

ABCDE onward
Card idPrice (EUR)MarketObservedName, quantity, what you paid…

2. Store the key outside the cells

Open Extensions → Apps Script, then Project Settings → Script Properties, and add a property named FLIPZI_KEY with your key as the value. The script reads it from there. Do not paste the key into a cell or into the code.

3. The script

Replace the contents of Code.gs with this, save, and reload the sheet. The menu appears after the reload.

const API = 'https://data.flipzi.io';
const BATCH = 25;          // ids per request: your plan's bulk cap
const CURRENCY = 'eur';    // or 'usd'

function onOpen() {
  SpreadsheetApp.getUi().createMenu('Flipzi')
    .addItem('Refresh prices', 'refreshPrices')
    .addToUi();
}

function flipziKey_() {
  const key = PropertiesService.getScriptProperties().getProperty('FLIPZI_KEY');
  if (!key) throw new Error('Add FLIPZI_KEY under Project Settings > Script Properties.');
  return key;
}

function refreshPrices() {
  const sheet = SpreadsheetApp.getActiveSheet();
  const lastRow = sheet.getLastRow();
  if (lastRow < 2) return;

  const ids = sheet.getRange(2, 1, lastRow - 1, 1).getValues()
    .map(row => String(row[0]).trim().toLowerCase());
  const found = {};

  const wanted = ids.filter(Boolean);
  for (let i = 0; i < wanted.length; i += BATCH) {
    const res = UrlFetchApp.fetch(API + '/v1/cards/bulk', {
      method: 'post',
      contentType: 'application/json',
      headers: { 'X-API-Key': flipziKey_() },
      payload: JSON.stringify({ card_ids: wanted.slice(i, i + BATCH), currency: CURRENCY, grade: 'RAW' }),
      muteHttpExceptions: true,
    });
    if (res.getResponseCode() !== 200) {
      throw new Error('Flipzi answered ' + res.getResponseCode() + ': ' + res.getContentText());
    }
    JSON.parse(res.getContentText()).data.forEach(row => {
      found[String(row.requested_id || row.card_id).toLowerCase()] = row.prices[0] || null;
    });
  }

  const out = ids.map(id => {
    const p = found[id];
    if (!id) return ['', '', ''];
    if (p === undefined) return ['unknown id', '', ''];
    if (p === null) return ['no price', '', ''];
    return [p.price_cents / 100, p.market, p.updated_at];
  });
  sheet.getRange(2, 2, out.length, 3).setValues(out);
}

The first run asks for permission to edit the sheet and to call an external service. Three outcomes are written per row: a price, no price for a card the API knows but cannot price today, and unknown id for a value in column A that is not a card id. A missing price is never written as 0, so a SUM over column B stays honest.

4. Find card ids without leaving the sheet

Add this function to the same file. It returns up to five matches as rows of id, name, set and number.

/**
 * Finds cards. Example: =FLIPZI_FIND("charizard ex", "pokemon", "125")
 * @customfunction
 */
function FLIPZI_FIND(name, game, number) {
  const params = ['q=' + encodeURIComponent(name), 'page_size=5',
                  'game=' + encodeURIComponent(game || 'pokemon')];
  if (number) params.push('number=' + encodeURIComponent(number));
  const res = UrlFetchApp.fetch(API + '/v1/cards/search?' + params.join('&'), {
    headers: { 'X-API-Key': flipziKey_() },
    muteHttpExceptions: true,
  });
  if (res.getResponseCode() !== 200) return 'Flipzi answered ' + res.getResponseCode();
  const cards = JSON.parse(res.getContentText()).data;
  if (!cards.length) return 'No match';
  return cards.map(c => [c.id, c.name, c.set.name, c.number]);
}

Type the formula in a scratch area, pick the right row, and paste its id as a value into column A. Then delete the formula: left in place it calls the API again whenever the sheet recalculates. Check set and number before you copy an id; the first match for a name is not always the card you own, and special printings are separate cards (printings and finishes).

If your list already has TCGplayer product ids, Cardmarket product ids or pokemontcg.io ids, GET /v1/cards/lookup converts them, and the bulk call accepts pokemontcg.io ids such as sv3-125 directly in column A.

5. Refresh on a schedule

In the Apps Script editor open Triggers, add a trigger for refreshPrices, choose Time-driven and a daily timer. Once a day is enough for a collection sheet. To keep a history, add a line at the end of refreshPrices that appends today's date and the column total to a second tab; the API returns per-card history (price history guide), but the value of your collection over time is yours to record.

Quota and limits

  • Units: the bulk call costs one unit per card, so a refresh costs as many units as the sheet has cards. A 200-card sheet refreshed daily is about 6,000 units a month.
  • Batch size: set BATCH to your plan's cap: 25 (Basic), 100 (Pro), 500 (Ultra), 750 (Mega); the free plan allows 25. A larger batch is refused with 422 BULK_LIMIT_EXCEEDED.
  • Refused, not half done: a batch that would exceed the remaining allowance returns 429 before anything is priced, and errors cost no units.
  • Graded cards: change grade to a code such as PSA_10, or add a grade column and group by it. Graded prices need Pro or above.
  • Use: the free plan is for development and evaluation. A sheet that runs a shop, a buylist or a client report needs a paid plan, which includes commercial use. See caching, storage and licensing.

Build the sheet on a free key

The free plan reaches the bulk call and search, so the whole sheet can be built and tested before you pick a plan.

Get a free API key Try it in the playground Compare API plans

Straight answers

How do I get trading card prices into Google Sheets?
Add an Apps Script to the sheet that calls a price API. With the Flipzi Data API, one POST /v1/cards/bulk request prices a batch of card ids, so a Refresh prices menu item can fill a price column for the whole sheet in a few calls.
Why not a formula in every row?
A custom function per row makes one API call per card and recalculates when the sheet does, which is slow and spends quota without you asking. A menu action prices the whole column in batches and runs only when you run it.
Is my API key safe in a spreadsheet?
Store it in the script's Script Properties, not in a cell or in the code. Anyone with edit access to the sheet can open the script project and read it, so do not share an editable copy of a sheet that holds a paid key.
Does this work for games other than Pokémon?
Yes. Card ids are the same kind of value in every game the API covers, including One Piece, Magic, Yu-Gi-Oh! and Lorcana, so one sheet can mix them.
Is the free plan enough for a personal sheet?
The free plan has 500 units a month at 5 requests a minute and is for development and evaluation only. It is enough to build the sheet and test it. For ongoing use, Basic has 15,000 units a month and includes commercial use.