Docs› Coverage› Pricing› Status› Support›
  1. Home
  2. Documentation
  3. Google Sheets

Greyhound racing API: Google Sheets

Google Sheets

Pull greyhound results into Google Sheets with a short Apps Script, your key kept out of the sheet.

Google Sheets

Sheets formulas cannot send a header, and keys never go in an address, so use a short Apps Script. It keeps your key in the script's settings, not in a cell anyone can see.

1. Store your key

In your sheet open Extensions, Apps Script, then Project settings, Script properties, and add a property named KEY holding your key.

2. Paste the script

Apps Script
function pull() {
  const key = PropertiesService.getScriptProperties().getProperty("KEY");
  const csv = UrlFetchApp.fetch("https://api.greyhoundracingapi.com/v1/results/yesterday.csv?country=GB",
    { headers: { "X-API-Key": key } }).getContentText();
  const rows = Utilities.parseCsv(csv), s = SpreadsheetApp.getActiveSheet();
  s.clear();
  if (rows.length) s.getRange(1, 1, rows.length, rows[0].length).setValues(rows);
}

3. Run it

Run pull once and allow access. To refresh on a schedule, add a time-driven trigger from the clock icon in Apps Script. A daily trigger fits the free key.