Google Sheets
Query the Koinju market-data database from a Google Sheet using a small Apps Script custom function.
Before you start
Host
the provided database URL
Port
8443
Protocol
HTTPS / SSL enabled
Database
api
User/Password
provided by Koinju
Don't have credentials yet? See How to connect.
Google Sheets has no native ClickHouse connector. The supported approach is a custom function backed by Apps Script, which calls the ClickHouse HTTPS interface for you.
Step-by-step
In your sheet, open Extensions ▸ Apps Script.
Delete any boilerplate and paste the script below, then Save.
In the Apps Script editor, open Project Settings ▸ Script Properties and add three properties:
CH_URL— the provided database host only (nohttps://, no port)CH_USER— the username provided by KoinjuCH_PASS— the password provided by Koinju
Back in the sheet, call the function from any cell, e.g.:
=CHQUERY("SELECT exchange, market, price FROM api.trade WHERE market LIKE 'BTC%' AND timestamp > toStartOfDay(now()) ORDER BY timestamp DESC LIMIT 20")
How it works:
It calls the ClickHouse HTTPS interface on port 8443 with HTTP Basic auth built from your Script Properties.
FORMAT TabSeparatedWithNamesis auto-appended (unless your SQL already ends in aFORMATclause), so the response is parsed into a 2D array that spills into a sheet range with a header row.Credentials live in Script Properties, never in cells — nobody viewing the sheet sees them.
Apps Script enforces a ~6-minute execution limit and response-size limits, so always filter by time and add a
LIMITto keep result sets small.
First sanity query
In any cell:
If ~20 rows spill into the sheet, you're connected. Next, explore what data is available in Data.
Last updated
Was this helpful?