services
Get a key

library / Integrations / I0046

Excel SOL price ticker

A Node script reads the SOL price from Carbium every 15 seconds and writes it to a CSV file. Excel loads that file through Power Query and refreshes a ticker cell on a timer, with each reading stamped by time and slot.

By Carbium · Spreadsheets and workspaces · I0046 · updated 2026-11-22

01

What you end up with

The goal is one Excel cell that shows the current SOL price and changes while the workbook is open. A small Node script reads the price from Carbium and writes it to a CSV file. Excel loads that file through Power Query and refreshes it on a timer.

The script depends on @solana/kit alone and never talks to Microsoft. The workbook needs no add-in and no macro, only a query and a formula.

PartWhereWhat happens
Readnode main.tsOne prices call and one getSlot call every 15 seconds.
Writesol_price.csvReplaced whole on each reading: a header and one row.
LoadData, Get Data, From File, From Text/CSVThe file becomes a table named sol_price.
RefreshQuery Properties, Refresh everyThe table reloads on the minute count you set.
Show=INDEX(sol_price[price],1)The latest price sits in any cell you choose.
02

The Solana side: one price call and one slot

Carbium answers price and quote calls on the same endpoint as plain RPC, https://services.carbium.sh. The quote plane has four methods: quote, swap, health and prices. The script calls prices with a fetch POST and carries the key in the x-api-key header, the same header the @solana/kit transport sends for the slot call.

A key without the QUOTE scope is refused on quote calls with 401 and code -32001, so give the key that scope in your account before the first run.

The script makes one prices call with an empty params list and reads the SOL price from the answer.

Each reading also carries a slot from getSlot at confirmed commitment. The time column dates each row and the slot places it on the chain, which is enough to line it up against other chain data.

getSlot is a cheap cached read and metered RPC work, with a 1-cell admission charge a call. The quote plane spends no credits. Four readings a minute stay far under the cheap-read rate of every plan, which starts at 5 req/s on Free.

03

The Excel side: load once, refresh on a timer

Start the script first, so sol_price.csv exists in its folder. Then, in desktop Excel:

  1. Open Data, Get Data, From File, From Text/CSV, pick sol_price.csv and choose Load. Excel creates a table named sol_price with the columns time, slot and price.
  2. Right-click the query in Queries and Connections, open Properties, tick Refresh every and enter a minute count. The smallest value is 1. Tick Refresh data when opening the file too.
  3. In a cell, enter =INDEX(sol_price[price],1). Put =INDEX(sol_price[time],1) beside it, so a stale ticker shows its age.
  4. To chart the day, load sol_history.csv the same way and insert a line chart on its price column.
!Load the file through the query and leave it closed as a workbook. On Windows a CSV open in Excel is locked, the script cannot replace it, and the cell keeps its last value until you close the file.

The script writes a temporary file and renames it over sol_price.csv, so a refresh never reads a half written row. The history file gets one appended row per reading and starts when you first run the script.

04

The script

Install the one dependency with npm install @solana/[email protected] and set "type": "module" in package.json. Node 24 strips the types on load. CARBIUM_KEY is required, and the script exits with a message when it is unset. CARBIUM_RPC_URL is optional. The one argument is the pause between readings in seconds, 15 by default, and 0 takes a single reading and exits.

main.ts
// I0046 · Excel SOL price ticker// https://carbium.sh/library/integrate/excel-sol-price-ticker// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { createDefaultRpcTransport, createSolanaRpcFromTransport } from "@solana/kit";import { appendFileSync, existsSync, renameSync, writeFileSync } from "node:fs";const key: string = process.env.CARBIUM_KEY ?? "";if (!key) {  console.error("Set CARBIUM_KEY to your Carbium API key.");  process.exit(1);}const url = process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh";const rpc = createSolanaRpcFromTransport(createDefaultRpcTransport({ url, headers: { "x-api-key": key } }));const SOL_MINT = "So11111111111111111111111111111111111111112";const seconds = Number(process.argv[2] ?? 15); // 0 takes one reading and exitsconst HEADER = "time,slot,price\n";type Prices = { solUsd?: unknown; rows?: unknown[][] };// One prices call with no params: solUsd is the SOL price, the SOL row of rows is the fallback.async function price(): Promise<number> {  const res = await fetch(url, {    method: "POST",    headers: { "content-type": "application/json", "x-api-key": key },    body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "prices", params: [] }),  });  const body = (await res.json().catch(() => ({}))) as { result?: Prices; error?: unknown };  if (!res.ok || body.error) throw new Error(`HTTP ${res.status} ${JSON.stringify(body.error ?? "")}`);  const n = Number(body.result?.solUsd ?? body.result?.rows?.find((r) => r[0] === SOL_MINT)?.[1]);  if (!(n > 0)) throw new Error("the prices answer carries no SOL price");  return n;}async function tick() {  const [p, s] = await Promise.allSettled([price(), rpc.getSlot({ commitment: "confirmed" }).send()]);  if (p.status === "rejected") return console.error(`price failed: ${p.reason}`);  if (s.status === "rejected") console.error(`slot failed: ${s.reason}`);  const row = `${new Date().toISOString()},${s.status === "fulfilled" ? s.value : ""},${p.value}\n`;  try {    writeFileSync("sol_price.tmp", HEADER + row);    renameSync("sol_price.tmp", "sol_price.csv"); // Excel never reads a half written file    if (!existsSync("sol_history.csv")) writeFileSync("sol_history.csv", HEADER);    appendFileSync("sol_history.csv", row);  } catch (e) {    console.error(`write failed: ${e}`);  }  console.log(row.trim());}do {  await tick();  if (seconds > 0) await new Promise((r) => setTimeout(r, seconds * 1000));} while (seconds > 0);

run: node main.ts

05

Run it and keep it running

Export CARBIUM_KEY and run node main.ts in the folder your query points at. Every reading prints one line, time,slot,price, and every failure prints to stderr. Stop it with Ctrl+C.

A failed reading does not stop the loop. The price call and the slot call run side by side, and each failure is printed on its own. A price failure skips the write, so the file keeps the last good row. Limits are per account, so your other keys draw on the same budget. The script treats a 429 as one failed reading, and the next tick is the retry.

To run it without a terminal, start it from Windows Task Scheduler at log on, or from a systemd user unit on Linux, with the working folder set to the one the query reads. The script keeps no state apart from the two files, so a restart carries on where the history ended.

06

Where it ends

  • The cell is polled. The script reads every 15 seconds, but Excel refreshes no more often than once a minute, so the cell can trail the file by up to a minute.
  • The price column holds the SOL price the prices call returns.
  • SOL only. A second token needs its own mint and its own column.
  • Excel for the web does not read a file from your disk, so the ticker works in desktop Excel.
  • The script has to be running. A sleeping machine writes no rows, and the history shows the gap.
  • It reads a price and moves no funds. A swap goes through the quote and swap methods, and swap builds an unsigned transaction you sign and send yourself.
07

When it goes wrong

what goes wrongwhat to do
The script prints price failed with HTTP 401.The key is unknown or lacks the QUOTE scope. Attach the whole key in CARBIUM_KEY and give it the QUOTE scope in your account. A quote call from a key without the scope answers 401 with code -32001.
The script prints slot failed and the slot column is empty.The getSlot call failed, for example on a 429 or a wrong CARBIUM_RPC_URL. The price is still written with an empty slot, and the next tick tries again.
The script prints price failed with -32601.The method name is wrong or not served. Do not retry; check the method and confirm the call says prices.
The script prints price failed with HTTP 429.The account's budget is spent, often by other keys on it. Raise the pause between readings or wait. The next tick retries by itself.
The script prints readings but the Excel cell never changes.The query has no refresh timer, or it points at a different folder than the one the script writes to. Check Properties on the query and the file path under Data Source Settings. Refresh All forces one reload.
The script prints write failed with EBUSY or EPERM.Another program holds the file, usually the CSV opened in Excel as a workbook. Close it, and the next reading replaces the file.
08

Questions

How often can the cell update?

As often as the Excel refresh timer fires, with a floor of one minute. The script can read every few seconds, and the history file keeps every reading for a chart.

Can a cell call Carbium directly with WEBSERVICE?

WEBSERVICE sends a GET and cannot carry the JSON body or the x-api-key header the call needs. Power Query's Web.Contents can POST with headers, but the key would then sit inside the workbook, readable by anyone you send it to. The script keeps it in an environment variable.

Does the ticker spend credits?

The quote plane spends none. getSlot is metered RPC work with a 1-cell admission charge a call.

Can the CSV live in a OneDrive or network folder my workbook already uses?

Yes. Run the script from that folder, or copy it there, and load the file from the same path with From Text/CSV. The script still has to rename a temporary file over the CSV, so the folder must let it write and rename.