Skip to content

chore(nodejs): js doc #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bca401e
chore(nodejs): extract transport from sender, add back support for co…
glasstiger Jul 16, 2025
7efb5ec
make linter happy
glasstiger Jul 16, 2025
0ddf668
more type fixes
glasstiger Jul 16, 2025
eb0d7ee
extract buffer from sender
glasstiger Jul 17, 2025
7f4d454
TimestampUnit type
glasstiger Jul 17, 2025
f54ad65
code formatting
glasstiger Jul 23, 2025
7a70a6d
feat(nodejs): protocol version option, binary protocol for doubles
glasstiger Jul 24, 2025
87c26a4
more tests
glasstiger Jul 24, 2025
c7b2525
feat(nodejs): array support
glasstiger Jul 26, 2025
46664d0
test unsupported array types
glasstiger Jul 29, 2025
2cdf4e5
more tests, better error message
glasstiger Jul 30, 2025
ab6f968
array validation
glasstiger Jul 31, 2025
094b83a
chore(nodejs): js doc
glasstiger Jul 31, 2025
591f740
Merge remote-tracking branch 'origin/main' into binary_protocol_arrays
glasstiger Jul 31, 2025
83455aa
formatting
glasstiger Jul 31, 2025
50adf5c
fix protocol_version doc
glasstiger Jul 31, 2025
e5a7dee
fix merge fallout
glasstiger Jul 31, 2025
dc29488
fix merge fallout
glasstiger Jul 31, 2025
3021396
fix merge fallout
glasstiger Jul 31, 2025
0ad1eca
js doc for buffer
glasstiger Jul 31, 2025
4880075
code formatting
glasstiger Jul 31, 2025
d873996
more js doc
glasstiger Jul 31, 2025
165d827
Merge branch 'binary_protocol_arrays' into arrays_support
glasstiger Jul 31, 2025
505a9bb
add back scheduled run of build
glasstiger Jul 31, 2025
0b75bb4
Merge branch 'arrays_support' into js_doc
glasstiger Aug 1, 2025
95d997f
remove redundant buffer overflow checks
glasstiger Aug 5, 2025
4f01717
js doc fix
glasstiger Aug 5, 2025
ccb6cab
js doc fix
glasstiger Aug 6, 2025
812d5b8
use request timeout and TLS settings from Sender options in '/setting…
glasstiger Aug 6, 2025
7c79739
use bracket notation for LINE_PROTO_SUPPORT_VERSION
glasstiger Aug 6, 2025
7ce8469
Merge branch 'binary_protocol_arrays' into arrays_support
glasstiger Aug 6, 2025
adf94c3
move writeArray() into buffer v2 from base
glasstiger Aug 6, 2025
d705546
Update src/utils.ts
glasstiger Aug 6, 2025
8ad622f
fix test
glasstiger Aug 6, 2025
c4feb7b
empty array support
glasstiger Aug 6, 2025
10d70c3
Merge branch 'arrays_support' into js_doc
glasstiger Aug 6, 2025
935fed3
Merge remote-tracking branch 'origin/main' into arrays_support
glasstiger Aug 6, 2025
3acd71f
handle zeros in arrays properly
glasstiger Aug 6, 2025
7d197f7
Merge branch 'arrays_support' into js_doc
glasstiger Aug 6, 2025
77926fe
js doc update
glasstiger Aug 6, 2025
3fe8062
Merge remote-tracking branch 'origin/main' into js_doc
glasstiger Aug 6, 2025
1f958d7
js doc update
glasstiger Aug 6, 2025
928c497
README update
glasstiger Aug 6, 2025
0bc0c8b
remove protocol version from example
glasstiger Aug 7, 2025
7bdaaa7
remove lic file
glasstiger Aug 7, 2025
317c85c
add back lic file
glasstiger Aug 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 57 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ The client requires Node.js v20 or newer version.
```shell
# With npm
npm i -s @questdb/nodejs-client

# With yarn
yarn add @questdb/nodejs-client

# With pnpm
pnpm add @questdb/nodejs-client
```

## Compatibility table

| QuestDB version | Node.js client version | HTTP Agent |
| --------------- | ---------------------- | ------------ |
| ^4.0.0 | >=v20.X.X | Undici Agent |
| ^3.0.0 | <v20.X.X | Http.Agent |
| QuestDB client version | Node.js version | HTTP Agent |
|------------------------| --------------- |--------------|
| ^4.0.0 | >=v20.X.X | Undici Agent |
| ^3.0.0 | <v20.X.X | Http Agent |

## Configuration options

Expand All @@ -38,39 +40,68 @@ For more details, please, check the <a href="https://questdb.github.io/nodejs-qu
import { Sender } from "@questdb/nodejs-client";

async function run() {
// create a sender using HTTP protocol
const sender = Sender.fromConfig("http::addr=127.0.0.1:9000");

// add rows to the buffer of the sender
await sender
.table("trades")
.symbol("symbol", "ETH-USD")
.symbol("side", "sell")
.floatColumn("price", 2615.54)
.floatColumn("amount", 0.00044)
.at(Date.now(), "ms");

// flush the buffer of the sender, sending the data to QuestDB
// the buffer is cleared after the data is sent, and the sender is ready to accept new data
await sender.flush();

// close the connection after all rows ingested
// unflushed data will be lost
await sender.close();
// create a sender
const sender = await Sender.fromConfig('http::addr=localhost:9000');

// order book snapshots
const orderBooks = [
{
symbol: 'BTC-USD',
exchange: 'COINBASE',
timestamp: Date.now(),
bidPrices: [50100.25, 50100.20, 50100.15, 50100.10, 50100.05],
bidSizes: [0.5, 1.2, 2.1, 0.8, 3.5],
askPrices: [50100.30, 50100.35, 50100.40, 50100.45, 50100.50],
askSizes: [0.6, 1.5, 1.8, 2.2, 4.0]
},
{
symbol: 'ETH-USD',
exchange: 'COINBASE',
timestamp: Date.now(),
bidPrices: [2850.50, 2850.45, 2850.40, 2850.35, 2850.30],
bidSizes: [5.0, 8.2, 12.5, 6.8, 15.0],
askPrices: [2850.55, 2850.60, 2850.65, 2850.70, 2850.75],
askSizes: [4.5, 7.8, 10.2, 8.5, 20.0]
}
];

try {
// add rows to the buffer of the sender
for (const orderBook of orderBooks) {
await sender
.table('order_book_l2')
.symbol('symbol', orderBook.symbol)
.symbol('exchange', orderBook.exchange)
.arrayColumn('bid_prices', orderBook.bidPrices)
.arrayColumn('bid_sizes', orderBook.bidSizes)
.arrayColumn('ask_prices', orderBook.askPrices)
.arrayColumn('ask_sizes', orderBook.askSizes)
.at(orderBook.timestamp, 'ms');
}

// flush the buffer of the sender, sending the data to QuestDB
// the buffer is cleared after the data is sent, and the sender is ready to accept new data
await sender.flush();
} finally {
// close the connection after all rows ingested
await sender.close();
}
}

run().then(console.log).catch(console.error);
```

### Authentication and secure connection

#### Username and password authentication

```javascript
import { Sender } from "@questdb/nodejs-client";

async function run() {
// create a sender using HTTPS protocol with username and password authentication
const sender = Sender.fromConfig(
"https::addr=127.0.0.1:9000;username=admin;password=quest;",
"https::addr=127.0.0.1:9000;username=admin;password=quest",
);

// send the data over the authenticated and secure connection
Expand All @@ -90,15 +121,15 @@ async function run() {
run().catch(console.error);
```

### TypeScript example
#### Token authentication

```typescript
import { Sender } from "@questdb/nodejs-client";

async function run(): Promise<void> {
// create a sender using HTTPS protocol with bearer token authentication
const sender: Sender = Sender.fromConfig(
"https::addr=127.0.0.1:9000;token=Xyvd3er6GF87ysaHk;",
"https::addr=127.0.0.1:9000;token=Xyvd3er6GF87ysaHk",
);

// send the data over the authenticated and secure connection
Expand Down
Loading