{
  "name": "Log daily gold, oil, Brent and EURUSD prices to Google Sheets with SiftingIO",
  "nodes": [
    {
      "parameters": {
        "content": "## Daily market snapshot \u2014 SiftingIO \u2192 Google Sheets\n\nEvery morning this workflow records:\n- Gold (`XAUUSD`)\n- WTI crude oil (`WTIUSD`)\n- Brent crude oil (`UKOUSD`)\n- EUR/USD (`EURUSD`)\n\n### Setup (about 5 minutes)\n1. Install `n8n-nodes-siftingio`\n2. Create a free API key:\n   https://sifting.io/register?utm_source=n8n&utm_medium=workflow_template&utm_campaign=daily_snapshot_sheets\n3. Select your SiftingIO credential on all four SiftingIO nodes\n4. Create a Google Sheet with these exact headers in row 1:\n   `timestamp_utc | gold_xauusd | wti_usd | brent_ukousd | eurusd | source`\n5. Open **Append snapshot to Google Sheets**\n6. Select your Google Sheets credential, spreadsheet, and sheet tab\n7. Click **Execute workflow** once; verify one row; then activate\n\nThe workflow imports inactive and contains no credentials or secrets.",
        "height": 650,
        "width": 480
      },
      "id": "12d99508-ba94-4829-9cb0-d577992576ba",
      "name": "Setup guide",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -800,
        -180
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 7
            }
          ]
        }
      },
      "id": "3e8a875e-5e8b-4c6a-b301-dda2c734771d",
      "name": "Every morning at 7am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -260,
        180
      ]
    },
    {
      "parameters": {
        "resource": "live",
        "operation": "getTrade",
        "venue": "commodities",
        "symbol": "XAUUSD"
      },
      "id": "85798604-438e-46b5-931e-835a75fbfb47",
      "name": "Get gold",
      "type": "n8n-nodes-siftingio.siftingIo",
      "typeVersion": 1,
      "position": [
        20,
        -60
      ]
    },
    {
      "parameters": {
        "resource": "live",
        "operation": "getTrade",
        "venue": "commodities",
        "symbol": "WTIUSD"
      },
      "id": "4f47eb75-bd0a-4d89-a74f-967c886d60c1",
      "name": "Get WTI",
      "type": "n8n-nodes-siftingio.siftingIo",
      "typeVersion": 1,
      "position": [
        20,
        100
      ]
    },
    {
      "parameters": {
        "resource": "live",
        "operation": "getTrade",
        "venue": "commodities",
        "symbol": "UKOUSD"
      },
      "id": "bad3958f-57e9-4632-9031-0121ea568f25",
      "name": "Get Brent",
      "type": "n8n-nodes-siftingio.siftingIo",
      "typeVersion": 1,
      "position": [
        20,
        260
      ]
    },
    {
      "parameters": {
        "resource": "live",
        "operation": "getTrade",
        "venue": "forex",
        "symbol": "EURUSD"
      },
      "id": "d6884ad2-c7ef-4669-9986-b9928be4d84d",
      "name": "Get EURUSD",
      "type": "n8n-nodes-siftingio.siftingIo",
      "typeVersion": 1,
      "position": [
        20,
        420
      ]
    },
    {
      "parameters": {},
      "id": "5efd328d-723c-458d-bc83-b3acd03b3d4e",
      "name": "Merge gold and WTI",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        300,
        20
      ]
    },
    {
      "parameters": {},
      "id": "91ceccb5-938c-43a9-8d52-e3eaa36576cc",
      "name": "Add Brent",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        500,
        150
      ]
    },
    {
      "parameters": {},
      "id": "49d7c486-2ee1-47a2-aed2-26e78f0442b8",
      "name": "Add EURUSD",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [
        700,
        250
      ]
    },
    {
      "parameters": {
        "jsCode": "function readPrice(payload) {\n  const candidates = [\n    payload.p, payload.price, payload.last, payload.last_price,\n    payload.c, payload.close, payload.mid, payload.m\n  ];\n  for (const value of candidates) {\n    const n = Number(value);\n    if (Number.isFinite(n)) return n;\n  }\n\n  const bid = Number(payload.b ?? payload.bid);\n  const ask = Number(payload.a ?? payload.ask);\n  if (Number.isFinite(bid) && Number.isFinite(ask)) return (bid + ask) / 2;\n\n  throw new Error(`No numeric price found in response: ${JSON.stringify(payload)}`);\n}\n\nreturn [{\n  json: {\n    timestamp_utc: new Date().toISOString(),\n    gold_xauusd: readPrice($('Get gold').first().json),\n    wti_usd: readPrice($('Get WTI').first().json),\n    brent_ukousd: readPrice($('Get Brent').first().json),\n    eurusd: readPrice($('Get EURUSD').first().json),\n    source: 'SiftingIO'\n  }\n}];"
      },
      "id": "e3d951e7-5bff-4065-b582-f71651a962f2",
      "name": "Build one spreadsheet row",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        920,
        250
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": ""
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": ""
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "timestamp_utc": "={{ $json.timestamp_utc }}",
            "gold_xauusd": "={{ $json.gold_xauusd }}",
            "wti_usd": "={{ $json.wti_usd }}",
            "brent_ukousd": "={{ $json.brent_ukousd }}",
            "eurusd": "={{ $json.eurusd }}",
            "source": "={{ $json.source }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "timestamp_utc",
              "displayName": "timestamp_utc",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "gold_xauusd",
              "displayName": "gold_xauusd",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "wti_usd",
              "displayName": "wti_usd",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "brent_ukousd",
              "displayName": "brent_ukousd",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "eurusd",
              "displayName": "eurusd",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true
            },
            {
              "id": "source",
              "displayName": "source",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": true,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "id": "8b1864ab-b2ef-4027-a78f-fe38ed61be8d",
      "name": "Append snapshot to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1160,
        250
      ]
    }
  ],
  "connections": {
    "Every morning at 7am": {
      "main": [
        [
          {
            "node": "Get gold",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get WTI",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Brent",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get EURUSD",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get gold": {
      "main": [
        [
          {
            "node": "Merge gold and WTI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get WTI": {
      "main": [
        [
          {
            "node": "Merge gold and WTI",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge gold and WTI": {
      "main": [
        [
          {
            "node": "Add Brent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Brent": {
      "main": [
        [
          {
            "node": "Add Brent",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Add Brent": {
      "main": [
        [
          {
            "node": "Add EURUSD",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get EURUSD": {
      "main": [
        [
          {
            "node": "Add EURUSD",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Add EURUSD": {
      "main": [
        [
          {
            "node": "Build one spreadsheet row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build one spreadsheet row": {
      "main": [
        [
          {
            "node": "Append snapshot to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "timezone": "UTC"
  },
  "active": false
}