Explore more topics
NexusTrade guides

Query market data in TypeScript

Submit bounded lake SQL and retrieve the durable schema and result manifest using the TypeScript SDK.

Jump to a section

TL;DR

Query market data with a lake scoped key, an explicit ticker and bounded dates, then inspect the completed manifest's schema and download the needed parts. The worked AAPL query returned five January 2024 sessions from the deployed canonical reader in 438 milliseconds. It verifies the source values, not the SDK's authenticated operation transport. Preserve adjusted closing prices and session timestamps when deriving metrics, and check coverage before treating empty results or query completion as evidence about today's data.

Follow one worked path

sdk request workflow diagram with review boundaries
Source-derived workflow diagram, not a screenshot or an external-client execution receipt.
Step 1 of 3

Install the shown SDK version

Create a registered API key with lake scope. Use the versioned /api/v1/nexustrade surface through the SDK. OAuth tokens for MCP are not SDK API keys.

What you should see

The matching package is available and the request uses the appropriate read, write or lake scope.

TypeScript
import { NexusTradeClient } from "nexustrade";
const client = new NexusTradeClient();

sdk request workflow diagram with review boundaries
Source-derived workflow diagram, not a screenshot or an external-client execution receipt.
Step 2 of 3

Run the bounded query

Run the exact bounded SQL example below. Preserve the adjusted-price basis and returned session timestamps.

What you should see

The durable query job returns schema and parts; read the actual returned values before treating them as market observations.

TypeScript
const query = await client.createLakeQuery(
  {
    query:
      "SELECT ticker, date, closingPrice FROM lake.sec_daily_ohlc " +
      "WHERE ticker = ? AND date::DATE BETWEEN CAST(? AS DATE) AND CAST(? AS DATE) " +
      "ORDER BY date ASC LIMIT 5",
    params: ["AAPL", "2024-01-02", "2024-01-08"],
    limits: { maxRows: 5 },
  },
  { idempotencyKey: "aapl-five-sessions-2024-v1" }
);
const finished = await client.waitForLakeQuery(query.id as string);
const manifest = await client.getLakeQueryManifest(finished.id as string);
console.log(manifest);

dataset version workflow diagram with review boundaries
Source-derived workflow diagram, not a screenshot or an external-client execution receipt.
Step 3 of 3

Inspect the returned artifact

Use the script's result-retrieval path and compare the returned dates, units and assumptions with the worked receipt below.

AAPL
Source timestamp (UTC): 2024-01-02T21:00:00.000Z · closingPrice (USD): 185.64
AAPL
Source timestamp (UTC): 2024-01-03T21:00:00.000Z · closingPrice (USD): 184.25
AAPL
Source timestamp (UTC): 2024-01-04T21:00:00.000Z · closingPrice (USD): 181.91
AAPL
Source timestamp (UTC): 2024-01-05T21:00:00.000Z · closingPrice (USD): 181.18
AAPL
Source timestamp (UTC): 2024-01-08T21:00:00.000Z · closingPrice (USD): 185.56
What you should see

The shown product receipt demonstrates its originating workflow, not proof that your local SDK request has executed.

Inspect the complete workflow outline

Actual output from the canonical lake reader

Show the table · 5 rows, 3 columns

Scroll sideways to compare all columns. Select a heading to sort.

AAPL2024-01-02T21:00:00.000Z185.64
AAPL2024-01-03T21:00:00.000Z184.25
AAPL2024-01-04T21:00:00.000Z181.91
AAPL2024-01-05T21:00:00.000Z181.18
AAPL2024-01-08T21:00:00.000Z185.56

We executed the exact bounded SQL below on the deployed NexusTrade lake worker on October 10, 2026. It returned these five AAPL sessions in 438 milliseconds, including setup. This verifies the canonical source query and returned values; the request used the synchronous lake reader rather than the SDK's authenticated query-operation transport.

The date values are the source's session timestamps. closingPrice is the catalog's adjusted series, so preserve that basis when comparing it with an unadjusted quote or deriving market capitalization.

Use a lake-scoped key

Create a registered API key with lake scope. Use the versioned /api/v1/nexustrade surface through the SDK. OAuth tokens for MCP are not SDK API keys.

TypeScript
import { NexusTradeClient } from "nexustrade";
const client = new NexusTradeClient();

Submit and read the manifest

Request at most five AAPL sessions from January 2 through January 8, 2024, sorted oldest first. Bind both dates and the ticker. sec_daily_ohlc is the catalog's canonical equity and ETF history; daily_ohlc is the legacy vendor table. The manifest describes durable parts and schema; download only the parts needed for your analysis.

TypeScript
const query = await client.createLakeQuery(
  {
    query:
      "SELECT ticker, date, closingPrice FROM lake.sec_daily_ohlc " +
      "WHERE ticker = ? AND date::DATE BETWEEN CAST(? AS DATE) AND CAST(? AS DATE) " +
      "ORDER BY date ASC LIMIT 5",
    params: ["AAPL", "2024-01-02", "2024-01-08"],
    limits: { maxRows: 5 },
  },
  { idempotencyKey: "aapl-five-sessions-2024-v1" }
);
const finished = await client.waitForLakeQuery(query.id as string);
const manifest = await client.getLakeQueryManifest(finished.id as string);
console.log(manifest);

Check coverage and availability dates

Show check coverage and availability dates

After completion, inspect the manifest schema and part metadata before downloading results. If the query returns no rows, review the ticker and dataset coverage before changing the query. If access is denied, check that the runtime key has lake scope. Catalog guidance records nullable fields, source coverage and point-in-time limitations. Preserve those caveats when showing derived metrics. Query completion is not proof the source includes today or that an event was public on its occurrence date.

Continue exploring

Discussion

Sign in or create a free account to join the discussion.

No comments yet.