Update a gold price field in Airtable with a scheduled automation. The automation script fetches the price from goldprice.dev and writes Price and Updated to your record.
1. Prepare your table
Create a table named Prices with a Number field named Price and a Date field named Updated.
2. Set the schedule
Create an automation with the trigger At a scheduled time. Choose when it should run.
3. Add the script action
Add the action Run a script and paste the automation script shown below. It writes the gold price to Price and the update date to Updated.
// Writes the live gold price (US dollars per troy ounce) and the time to one record in Prices.const { apiKey, recordId } = input.config()const res = await fetch('https://api.goldprice.dev/v1/prices?symbol=XAU-USD-SPOT', { headers: { 'X-API-Key': apiKey } })if (!res.ok) throw new Error(`goldprice.dev answered ${res.status}`)const { symbols } = await res.json()const price = Number(symbols[0].price)await base.getTable('Prices').updateRecordAsync(recordId, { Price: price, Updated: new Date().toISOString() })output.set('price', price)4. Set the input variables
Get a free goldprice.dev API key. In the script settings, set apiKey to your key and recordId to the ID of the record you want to update.
Input values are visible to anyone who can edit the automation.