TypeScript SDK
Install:
npm install @gfin/sdk
Create a client:
import { Client } from "@gfin/sdk";
const client = new Client({ contact: "you@example.com" });
Core Calls
const search = await client.search("apple");
const research = await client.research("Why is AAPL moving today?");
const summary = await client.quoteSummary("AAPL", { exchange: "NASDAQ" });
const financials = await client.quoteFinancials("AAPL", { exchange: "NASDAQ" });
const news = await client.news({ limit: 5 });
const markets = await client.marketSummary();
Quote Views
await client.quoteSummary("AAPL", { exchange: "NASDAQ" });
await client.quoteDetails("AAPL", { exchange: "NASDAQ" });
await client.quoteEntityDetails("AAPL", { exchange: "NASDAQ" });
await client.quoteHistory("AAPL", { exchange: "NASDAQ" });
await client.quoteFinancials("AAPL", { exchange: "NASDAQ" });
await client.quoteEarnings("AAPL", { exchange: "NASDAQ" });
await client.quoteRelated("AAPL", { exchange: "NASDAQ" });
await client.quoteSentiment("AAPL", { exchange: "NASDAQ" });
Or choose a view dynamically:
await client.quote("AAPL", "summary", { exchange: "NASDAQ" });
await client.quoteView("AAPL", "earnings", { exchange: "NASDAQ" });
Realtime Routes
await client.realtimeSnapshots(["/m/0cqyw", "/m/016yss"]);
await client.realtimeTrendLines(["/m/0cqyw", "/m/016yss"]);
Configuration
const client = new Client({
baseUrl: "https://api.gfin.dev",
contact: "you@example.com",
apiKey: "gfin_...",
timeoutMs: 10_000,
});
Node-like runtimes can also use:
export GFIN_BASE_URL=https://api.gfin.dev
export GFIN_CONTACT=you@example.com
export GFIN_API_KEY=gfin_...
Errors
import { Client, GfinError, GfinRateLimitError } from "@gfin/sdk";
const client = new Client({ contact: "you@example.com" });
try {
await client.research("Why is AAPL moving today?");
} catch (error) {
if (error instanceof GfinRateLimitError) {
console.log("retry after", error.retryAfterSeconds);
} else if (error instanceof GfinError) {
console.log(error.status, error.code);
}
}
The SDK has no runtime dependencies and uses standard fetch.