Skip to main content

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:

For most agents, expose a small set of read-only tools first:

ToolBacking routeUse
get_quote/v1/quoteCurrent quote data for one or more symbols.
get_history/v1/historyHistorical candles for one symbol.
search_symbols/v1/searchTurn user text into ticker candidates.
get_options_chain/v1/optionsOption expirations and calls/puts.
get_fundamentals/v1/fundamentalsProfile, 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 period and interval for historical charts.
  • Treat missing fields as unavailable data, not as zero.
  • Retry 429 responses after the Retry-After value.
  • 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: [email protected]"

Example TypeScript Agent Helper

import { Client } from "@yfin/sdk";

const yfin = new Client({ contact: "[email protected]" });

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.