FlashAlpha JavaScript SDK
Official JavaScript & TypeScript SDK. Runs in Node 18+, Deno, Bun, Cloudflare Workers, and modern browsers — zero dependencies, native fetch.
npm install flashalpha
What the SDK gives you
Full endpoint coverage
Every REST endpoint — market data, exposure (GEX/DEX/VEX/CHEX), volatility, pricing, screener, account — is a method on the client.
Zero dependencies
Uses native fetch. Works unchanged in Node 18+, Bun, Deno, Cloudflare Workers, Vercel Edge, and browsers.
TypeScript-first
Type declarations ship with the package. IDE autocomplete on every method and option.
Typed error classes
AuthenticationError, TierRestrictedError, RateLimitError, NotFoundError, ServerError — use instanceof to branch.
Custom fetch injection
Override fetch to add logging, retries, caching, or a testing mock — without forking the client.
Live options screener
Build filter/sort/select queries as plain objects. Alpha-tier formulas and cascading filters included.
Install
npm install flashalpha
# or
yarn add flashalpha
# or
pnpm add flashalpha
Requires Node 18+ (for native fetch). No Polyfill needed in browsers or serverless runtimes.
Quick start
import { FlashAlpha } from 'flashalpha';
const fa = new FlashAlpha('YOUR_API_KEY');
// Gamma exposure for SPY
const gex = await fa.gex('SPY');
console.log(gex.net_gex, gex.gamma_flip);
// Key support / resistance levels
const { levels } = await fa.exposureLevels('SPY');
console.log(levels.call_wall, levels.put_wall);
// BSM greeks for a single contract
const g = await fa.greeks({ spot: 655, strike: 660, dte: 7, sigma: 0.18, type: 'call' });
console.log(g.delta, g.gamma, g.theta);
// Plan & quota usage
console.log(await fa.account());
Live options screener
// Vol scanner with an inline formula (Alpha tier)
const result = await fa.screener({
formulas: [{ alias: 'iv_premium', expression: 'atm_iv - rv_20d' }],
filters: { formula: 'iv_premium', operator: 'gte', value: 5 },
sort: [{ formula: 'iv_premium', direction: 'desc' }],
select: ['symbol', 'atm_iv', 'rv_20d', 'iv_premium'],
limit: 20,
});
for (const row of result.data) {
console.log(row.symbol, row.iv_premium);
}
Common recipes
TypeScript: typed screener row
type Row = { symbol: string; price: number; net_gex: number; regime: string };
type ScreenerResp = { meta: { returned_count: number }; data: Row[] };
const res = (await fa.screener({
sort: [{ field: 'net_gex', direction: 'desc' }],
select: ['symbol', 'price', 'net_gex', 'regime'],
limit: 10,
})) as ScreenerResp;
res.data.forEach(r => console.log(r.symbol, r.net_gex));
Next.js server action / route handler
// app/api/gex/[symbol]/route.ts
import { FlashAlpha } from 'flashalpha';
const fa = new FlashAlpha(process.env.FLASHALPHA_KEY!);
export async function GET(_req: Request,
{ params }: { params: { symbol: string } }) {
const gex = await fa.gex(params.symbol);
return Response.json(gex);
}
Testing with a mocked fetch
const fakeFetch = async (_url: string, _init?: RequestInit) =>
new Response(JSON.stringify({ net_gex: 123, gamma_flip: 650 }),
{ status: 200, headers: { 'content-type': 'application/json' }});
const fa = new FlashAlpha('test-key', { fetch: fakeFetch });
expect(await fa.gex('SPY')).toEqual({ net_gex: 123, gamma_flip: 650 });
Method catalog
| Category | Methods | Tier |
|---|---|---|
| Market data | stockQuote, optionQuote, stockSummary, surface | Free / Growth |
| Historical replay (point-in-time) | historicalStockQuote, historicalOptionQuote, plus the full live API mirrored on historical.flashalpha.com via new FlashAlpha({ apiKey, baseUrl: "https://historical.flashalpha.com" }) with at param | Alpha |
| Exposure (basic) | gex, exposureLevels | Free+ (equities); Basic+ for ETFs & indexes |
| Exposure (Greeks) | dex, vex, chex, maxpain | Basic+ |
| Exposure (Growth) | exposureSummary, narrative, zeroDte, exposureHistory | Growth+ |
| Pricing | greeks, iv, kelly | Free / Growth |
| Volatility | volatility, advVolatility | Growth / Alpha |
| Screener | screener | Growth+ |
| Reference | tickers, options, symbols | Free+ |
| Account | account, health | Free+ |
Error handling
import {
FlashAlpha,
FlashAlphaError,
AuthenticationError,
TierRestrictedError,
NotFoundError,
RateLimitError,
ServerError,
} from 'flashalpha';
const fa = new FlashAlpha('YOUR_API_KEY');
try {
const out = await fa.narrative('SPY');
} catch (e) {
if (e instanceof TierRestrictedError) {
console.log(`Upgrade to ${e.requiredPlan}`);
} else if (e instanceof RateLimitError) {
console.log(`Retry after ${e.retryAfter}s`);
} else if (e instanceof FlashAlphaError) {
console.log(`API error ${e.statusCode}: ${e.message}`);
} else {
throw e;
}
}
| HTTP | Class | Properties |
|---|---|---|
| 401 | AuthenticationError | — |
| 403 | TierRestrictedError | currentPlan, requiredPlan |
| 404 | NotFoundError | — |
| 429 | RateLimitError | retryAfter |
| 5xx | ServerError | statusCode |
| other | FlashAlphaError | statusCode |
Client configuration
const fa = new FlashAlpha('YOUR_API_KEY', {
baseUrl: 'https://lab.flashalpha.com', // default
timeout: 30_000, // milliseconds
fetch: customFetch, // optional override
});
Injecting a custom fetch is the easiest way to add request-level retries, logging, or a test double. The override receives the same (url, init) signature as global fetch.
Links
- flashalpha-js on GitHub
- flashalpha on npm
- Lab API overview — endpoints, tiers, error model
- Live screener spec — filter grammar, fields, formulas
- Screener cookbook — ready-to-paste recipes
Ready to build?
Get your free API key and start pulling live options data in 30 seconds.