Interfaces
Core SDK
@stocksync/core is the library the CLI, the MCP server and the StockSync website are built on. It
reads the Robinhood Stock Token API, Robinhood Chain and Chainlink price feeds, validates every
response, and returns typed, read-only results.
Create a client
Create one client per process and reuse it. The client owns the response cache, so repeated calls share upstream requests and concurrent calls for the same data make one request.
resolveConfig validates the STOCKSYNC_* environment variables described in
Chain configuration and throws CONFIG_INVALID without echoing their values.
Methods
inspectStockToken(stocksync, symbolOrAddress) combines the registry entry, verification, quote,
multiplier, trading status and corporate actions for one token. Each section degrades on its own: a
failed quote becomes price: null with a SECTION_UNAVAILABLE warning instead of failing the whole
inspection.
Results
Every data method resolves to a Sourced<T>:
What each field means, and how to decide whether data is stale, is covered in Data semantics.
Request options
Every data method accepts { signal, fresh }:
signal: anAbortSignal. Cancelled requests are never retried.fresh: bypass the cache for this call. The fresh response is still cached for later calls.
Errors
Methods throw only StockSyncError, with a stable code and a retryable flag. Lookups that can
legitimately find nothing (getAsset, getAssetByAddress, getOraclePrice) return data: null
instead of throwing.
The full list is in Errors and warnings.
Example: refuse a contract that is not canonical
Example: read a price with its basis
Runtime notes
- Use the SDK on servers. It depends on viem, and configured RPC URLs often contain API keys.
- Numeric values are decimal strings, never floating-point numbers. Use
compareDecimals,multiplyDecimalsanddivideDecimalsfrom the package when you need arithmetic.