@troystack/sdk
v0.1.0
Published
TypeScript SDK for the TroyStack precious metals API
Maintainers
Readme
@troystack/sdk
TypeScript SDK for the TroyStack precious metals API.
Install
npm install @troystack/sdkQuick Start
import { 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.
API Reference
Public Methods (no API key required)
| 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 |
Authenticated Methods (API key required)
| 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 |
Error Handling
import { TroyStack, TroyStackApiError } from "@troystack/sdk";
try {
const data = await troy.portfolio();
} catch (err) {
if (err instanceof TroyStackApiError) {
console.error(err.status, err.message);
}
}Documentation
Full API docs at troystack.com/developers
License
MIT
