{"id":28455685,"url":"https://github.com/questdb/nodejs-questdb-client","last_synced_at":"2025-06-27T02:31:35.375Z","repository":{"id":49498120,"uuid":"513543581","full_name":"questdb/nodejs-questdb-client","owner":"questdb","description":"QuestDB Node.js Client","archived":false,"fork":false,"pushed_at":"2024-08-20T09:03:06.000Z","size":7774,"stargazers_count":42,"open_issues_count":13,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-25T12:50:22.130Z","etag":null,"topics":["async-await","client-library","javascript","nodejs","questdb","questdb-ilp-client","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/questdb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-13T14:00:50.000Z","updated_at":"2025-05-06T12:29:43.000Z","dependencies_parsed_at":"2023-11-27T18:29:29.039Z","dependency_job_id":"10d36642-1247-447f-9179-f15443583f90","html_url":"https://github.com/questdb/nodejs-questdb-client","commit_stats":{"total_commits":80,"total_committers":7,"mean_commits":"11.428571428571429","dds":"0.15000000000000002","last_synced_commit":"83c7b19b106c99a01ad31aab6a34263db5d3460d"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/questdb/nodejs-questdb-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Fnodejs-questdb-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Fnodejs-questdb-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Fnodejs-questdb-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Fnodejs-questdb-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/questdb","download_url":"https://codeload.github.com/questdb/nodejs-questdb-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questdb%2Fnodejs-questdb-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262177649,"owners_count":23270910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async-await","client-library","javascript","nodejs","questdb","questdb-ilp-client","typescript"],"created_at":"2025-06-06T22:10:21.852Z","updated_at":"2025-06-27T02:31:35.364Z","avatar_url":"https://github.com/questdb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QuestDB Node.js Client\n\n## Requirements\n\nThe client requires Node.js v16 or newer version.\n\n## Installation\n```shell\nnpm i -s @questdb/nodejs-client\n```\n\n## Configuration options\n\nDetailed description of the client's configuration options can be found in\nthe \u003ca href=\"https://questdb.github.io/nodejs-questdb-client/SenderOptions.html\"\u003eSenderOptions\u003c/a\u003e documentation.\n\n## Examples\n\nThe examples below demonstrate how to use the client. \u003cbr\u003e\nFor more details, please, check the \u003ca href=\"https://questdb.github.io/nodejs-questdb-client/Sender.html\"\u003eSender\u003c/a\u003e's documentation.\n\n### Basic API usage\n\n```javascript\nconst { Sender } = require(\"@questdb/nodejs-client\")\n\nasync function run() {\n  // create a sender using HTTP protocol\n  const sender = Sender.fromConfig(\"http::addr=127.0.0.1:9000\")\n\n  // add rows to the buffer of the sender\n  await sender\n    .table(\"trades\")\n    .symbol(\"symbol\", \"ETH-USD\")\n    .symbol(\"side\", \"sell\")\n    .floatColumn(\"price\", 2615.54)\n    .floatColumn(\"amount\", 0.00044)\n    .at(Date.now(), \"ms\")\n\n  // flush the buffer of the sender, sending the data to QuestDB\n  // the buffer is cleared after the data is sent, and the sender is ready to accept new data\n  await sender.flush()\n\n  // close the connection after all rows ingested\n  // unflushed data will be lost\n  await sender.close()\n}\n\nrun().then(console.log).catch(console.error)\n```\n\n### Authentication and secure connection\n\n```javascript\nconst { Sender } = require(\"@questdb/nodejs-client\")\n\nasync function run() {\n    // create a sender using HTTPS protocol with username and password authentication\n    const sender = Sender.fromConfig(\"https::addr=127.0.0.1:9000;username=admin;password=quest;\")\n\n    // send the data over the authenticated and secure connection\n    await sender\n        .table(\"trades\")\n        .symbol(\"symbol\", \"ETH-USD\")\n        .symbol(\"side\", \"sell\")\n        .floatColumn(\"price\", 2615.54)\n        .floatColumn(\"amount\", 0.00044)\n        .at(Date.now(), \"ms\")\n    await sender.flush()\n\n    // close the connection after all rows ingested\n    await sender.close()\n}\n\nrun().catch(console.error)\n```\n\n### TypeScript example\n\n```typescript\nimport { Sender } from \"@questdb/nodejs-client\"\n\nasync function run(): Promise\u003cvoid\u003e {\n    // create a sender using HTTPS protocol with bearer token authentication\n    const sender: Sender = Sender.fromConfig(\"https::addr=127.0.0.1:9000;token=Xyvd3er6GF87ysaHk;\")\n\n    // send the data over the authenticated and secure connection\n    await sender\n        .table(\"trades\")\n        .symbol(\"symbol\", \"ETH-USD\")\n        .symbol(\"side\", \"sell\")\n        .floatColumn(\"price\", 2615.54)\n        .floatColumn(\"amount\", 0.00044)\n        .at(Date.now(), \"ms\")\n    await sender.flush()\n\n    // close the connection after all rows ingested\n    await sender.close()\n}\n\nrun().catch(console.error);\n```\n\n### Worker threads example\n\n```javascript\nconst { Sender } = require(\"@questdb/nodejs-client\")\nconst { Worker, isMainThread, parentPort, workerData } = require(\"worker_threads\")\n\n// fake venue\n// generates random prices and amounts for a ticker for max 5 seconds, then the feed closes\nfunction* venue(ticker) {\n    let end = false\n    setTimeout(() =\u003e { end = true; }, rndInt(5000))\n    while (!end) {\n        yield {ticker, price: Math.random(), amount: Math.random()}\n    }\n}\n\n// market data feed simulator\n// uses the fake venue to deliver price and amount updates to the feed handler (onTick() callback)\nasync function subscribe(ticker, onTick) {\n    const feed = venue(workerData.ticker)\n    let tick;\n    while (tick = feed.next().value) {\n        await onTick(tick)\n        await sleep(rndInt(30))\n    }\n}\n\nasync function run() {\n    if (isMainThread) {\n        const tickers = [\"ETH-USD\", \"BTC-USD\", \"SOL-USD\", \"DOGE-USD\"]\n        // main thread to start a worker thread for each ticker\n        for (let ticker of tickers) {\n            const worker = new Worker(__filename, { workerData: { ticker: ticker } })\n                .on('error', (err) =\u003e { throw err; })\n                .on('exit', () =\u003e { console.log(`${ticker} thread exiting...`); })\n                .on('message', (msg) =\u003e {\n                    console.log(`Ingested ${msg.count} prices for ticker ${msg.ticker}`)\n                });\n        }\n    } else {\n        // it is important that each worker has a dedicated sender object\n        // threads cannot share the sender because they would write into the same buffer\n        const sender = Sender.fromConfig(\"http::addr=127.0.0.1:9000\");\n\n        // subscribe for the market data of the ticker assigned to the worker\n        // ingest each price update into the database using the sender\n        let count = 0;\n        await subscribe(workerData.ticker, async (tick) =\u003e {\n            await sender\n                .table(\"trades\")\n                .symbol(\"symbol\", tick.ticker)\n                .symbol(\"side\", \"sell\")\n                .floatColumn(\"price\", tick.price)\n                .floatColumn(\"amount\", tick.amount)\n                .at(Date.now(), \"ms\")\n            await sender.flush();\n            count++;\n        });\n\n        // let the main thread know how many prices were ingested\n        parentPort.postMessage({ticker: workerData.ticker, count})\n\n        // close the connection to the database\n        await sender.close()\n    }\n}\n\nfunction sleep(ms) {\n    return new Promise(resolve =\u003e setTimeout(resolve, ms))\n}\n\nfunction rndInt(limit) {\n    return Math.floor((Math.random() * limit) + 1)\n}\n\nrun()\n    .then(console.log)\n    .catch(console.error)\n```\n\n## Community\n\nIf you need help, have additional questions or want to provide feedback, you\nmay find us on our [Community Forum](https://community.questdb.io/).\n\nYou can also [sign up to our mailing list](https://questdb.io/contributors/)\nto get notified of new releases.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquestdb%2Fnodejs-questdb-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquestdb%2Fnodejs-questdb-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquestdb%2Fnodejs-questdb-client/lists"}