AI Agents
yfin works well for agents because it exposes stable REST routes, OpenAPI schemas, SDKs, and simple request limits. Give agents the smallest context that lets them call the API correctly.
Minimal Agent Context
Provide these links or files:
Recommended Tool Shape
For most agents, expose a small set of read-only tools first:
| Tool | Backing route | Use |
|---|---|---|
get_quote | /v1/quote | Current quote data for one or more symbols. |
get_history | /v1/history | Historical candles for one symbol. |
search_symbols | /v1/search | Turn user text into ticker candidates. |
get_options_chain | /v1/options | Option expirations and calls/puts. |
get_fundamentals | /v1/fundamentals | Profile, valuation, and financial data modules. |
Agent Prompt Notes
Tell the agent:
- Search before quoting when the user provides a company name instead of a ticker.
- Batch quote requests with comma-separated symbols.
- Use
periodandintervalfor historical charts. - Treat missing fields as unavailable data, not as zero.
- Retry 429 responses after the
Retry-Aftervalue. - Use the OpenAPI file for exact response schemas.
Example REST Call
curl "https://api.yfin.dev/v1/quote?symbols=AAPL,MSFT" \
-H "X-Yfin-Contact: agent@example.com"
Example TypeScript Agent Helper
import { Client } from "@yfin/sdk";
const yfin = new Client({ contact: "agent@example.com" });
export async function getQuote(symbols: string[]) {
return yfin.quote(symbols);
}
export async function getHistory(symbol: string, period = "1mo", interval = "1d") {
return yfin.history(symbol, { period, interval });
}
Guardrails
- Keep API keys out of prompts and transcripts.
- Use environment variables for credentials.
- Prefer stable operation names from the OpenAPI document when generating tools.
- Keep a small retry budget for temporary failures.