Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.vectrade.io/llms.txt

Use this file to discover all available pages before exploring further.

Installation

npm install @vectrade/sdk

Runtime Support

RuntimeVersionStatus
Node.js18+✅ Full support
Deno1.28+✅ Full support
Bun1.0+✅ Full support
Cloudflare Workers✅ Full support
Zero runtime dependencies — uses native fetch and Web Crypto APIs.

Quick Start

import { VecTrade } from "@vectrade/sdk";

const client = new VecTrade(); // reads VECTRADE_API_KEY env var

const quote = await client.quotes.get("AAPL");
console.log(`${quote.symbol}: $${quote.price}`);

Configuration

const client = new VecTrade({
  apiKey: "vq_live_...",   // or VECTRADE_API_KEY env var
  baseURL: "https://...",  // custom endpoint
  timeout: 30000,          // request timeout (ms)
  maxRetries: 2,           // automatic retries on 429/5xx
  sandbox: true,           // use sandbox environment
});

Resources

All 11 API resource groups are available:
ResourceMethods
client.quotesget(symbol), batch(symbols)
client.fundamentalsget(symbol), incomeStatement(symbol), balanceSheet(symbol)
client.technicalsget(symbol, options)
client.newslist(options), get(id)
client.screenerscreen(filters)
client.aianalyze(prompt) — supports streaming
client.optionschain(symbol, options), expirations(symbol)
client.analystconsensus(symbol), priceTargets(symbol), ratings(symbol)
client.earningshistory(symbol), calendar()
client.insidertransactions(symbol), summary(symbol)
client.webhookscreate(url, events), list(), delete(id)

Streaming

const stream = await client.ai.analyze("Analyze AAPL", { stream: true });

for await (const chunk of stream) {
  process.stdout.write(chunk.content);
}

Pagination

const paginator = client.news.list({ limit: 100 });

for await (const article of paginator) {
  console.log(article.title);
}

// Or collect all at once
const all = await paginator.toArray();

Webhook Verification

import { verifyWebhook } from "@vectrade/sdk";

const event = await verifyWebhook(rawBody, headers, secret);
// Validates HMAC-SHA256 signature + timestamp (replay protection)

Error Handling

import { RateLimitError, NotFoundError } from "@vectrade/sdk";

try {
  const quote = await client.quotes.get("INVALID");
} catch (err) {
  if (err instanceof NotFoundError) {
    console.log(`Not found (request_id: ${err.requestId})`);
  } else if (err instanceof RateLimitError) {
    console.log(`Rate limited, retry after ${err.retryAfter}s`);
  }
}

Vercel AI SDK Integration

import { createVecTrade } from "@vectrade/ai-provider";
import { generateText } from "ai";

const vt = createVecTrade();
const result = await generateText({
  model: yourModel,
  tools: vt.tools(),
  prompt: "What's AAPL trading at?",
});

Security

  • API key is non-enumerable — hidden from console.log and JSON.stringify
  • Webhook verification uses constant-time comparison (double-HMAC)
  • Replay protection via timestamp tolerance window

GitHub

Source code, issues, and contributions