TypeScript SDK for the TroyStack precious metals API.
npm install @troystack/sdkimport { TroyStack } from "@troystack/sdk";
const troy = new TroyStack(); // no key needed for public endpoints
const prices = await troy.spot();
console.log(prices);For authenticated endpoints, pass your API key:
const troy = new TroyStack("ts_your_api_key");
const brief = await troy.dailyBrief();Or set the TROYSTACK_API_KEY environment variable.
| Method | Description |
|---|---|
spot() |
Current spot prices for all metals |
priceHistory(metal, range?) |
Historical price data. Range: 1d, 1w, 1m, 3m, 1y, 5y |
signal(limit?) |
Stack Signal articles (market intelligence) |
signalLatest() |
Most recent Stack Signal article |
comex(metal?) |
COMEX vault watch data |
junkSilver(coins) |
Junk silver melt value calculator |
whatIf(targets) |
Speculation / what-if price scenarios |
purchasingPower(metal, ounces) |
Current purchasing power of a metal position |
| Method | Description |
|---|---|
ask(question) |
Ask Troy AI a question |
portfolio() |
Get your portfolio |
addHolding(holding) |
Add a holding to your portfolio |
analytics() |
Portfolio analytics and allocation |
dailyBrief() |
Personalized daily market brief |
import { TroyStack, TroyStackApiError } from "@troystack/sdk";
try {
const data = await troy.portfolio();
} catch (err) {
if (err instanceof TroyStackApiError) {
console.error(err.status, err.message);
}
}Full API docs at troystack.com/developers
MIT