Skip to main content

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.ticker}: $${quote.price}`);

Configuration

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

Resources

All 12 resource groups available:
ResourceMethods
client.quotesget(symbol), batch(symbols)
client.fundamentalsget(symbol), statements(symbol)
client.technicalsget(symbol)
client.newslist(symbol)
client.optionschain(symbol)
client.analystconsensus(symbol), priceTargets(symbol), ratings(symbol)
client.earningshistory(symbol)
client.insidertransactions(symbol)
client.profileget(symbol)
client.sentimentget(symbol)
client.historicalget(symbol, { period })
client.etfget(symbol)

Usage Examples

Batch Quotes

const quotes = await client.quotes.batch(["AAPL", "MSFT", "GOOGL"]);
for (const q of quotes) {
  console.log(`${q.ticker}: $${q.price.toFixed(2)} (${q.change_percent}%)`);
}

Technical Analysis

const tech = await client.technicals.get("AAPL");
console.log(`Score: ${tech.technical_score}/100`);
console.log(`RSI: ${tech.indicators?.rsi?.value} (${tech.indicators?.rsi?.signal})`);
console.log(`Trend: ${tech.summary?.trend}`);

Analyst Consensus

const analyst = await client.analyst.consensus("AAPL");
console.log(`${analyst.consensus} | Signal: ${analyst.signal}`);

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