Developer API docs

Chart image endpoint

Embed 1600×900 PNG charts of stock fundamentals with one URL: revenue, EPS, margins, daily P/E and other valuation lines, attribution and as-of date in frame.

Documentation updated 2026-09-02. Machine-readable: openapi.json · llms.txt

Endpoint

GET https://tgmcharts.com/api/v1/charts/{symbol}/{metric} renders a 1600×900 PNG (image/png) of the metric's stored history in TGMCharts' own chart style: line charts for daily valuation and yield series, bars for annual, quarterly and TTM statement series. The TGMCharts wordmark and the data-as-of footer are part of the frame — they are the attribution required by the API terms and no parameter removes them.

Query parameterValuesBehavior
yearsinteger 2–20Trailing window. Defaults by basis: 20 years for daily and monthly lines, 10 for annual bars, 3 for quarterly and TTM bars.
comparea second tickerGrouped comparison bars, bar-chart metrics only. When either series has a negative value the render falls back to the primary series and says so in the subhead.
periodannual | quarterly | ttm | dailyBasis alias — 308 to the canonical per-basis slug, like the series endpoint.
HTML embed
<img src="https://tgmcharts.com/api/v1/charts/AAPL/revenue"
     width="800" height="450" alt="AAPL annual revenue — data by TGMCharts" />
Markdown (README, issue, newsletter)
![KO dividend yield, 20 years](https://tgmcharts.com/api/v1/charts/KO/dividend-yield?years=20)
Comparison bars
https://tgmcharts.com/api/v1/charts/KO/revenue?compare=PEP

What is in the frame

  • Line series are downsampled to at most 300 evenly spaced points; bar series show the most recent 22 periods of the window.
  • The headline shows the latest value in the window; the subhead states the basis (daily series, sampled about monthly, by fiscal year, by fiscal quarter, rolling trailing-twelve-month) and the year span; the footer carries the data-as-of date.
  • A metric that is not meaningful for the company type, or a symbol with no stored history for it, renders an explanation card at 200 — an <img> embed degrades into a readable reason, never blank space or an invented series.
  • Renders read stored, precomputed data only; no request waits on a live market-data call.

Chart metrics

Generated from the registry the endpoint reads. ?compare= is accepted on bar charts only.

MetricSlugBasisChartDefault window?compare=
P/E Ratiope-ratiodailyline20 yearsno (line)
P/S Ratiops-ratiodailyline20 yearsno (line)
P/B Ratiopb-ratiodailyline20 yearsno (line)
P/FCF Ratiopfcf-ratiodailyline20 yearsno (line)
P/OCF Ratiopocf-ratiodailyline20 yearsno (line)
EV/EBITDAev-ebitdadailyline20 yearsno (line)
EV/EBITev-ebitdailyline20 yearsno (line)
EV/Salesev-salesdailyline20 yearsno (line)
EV/FCFev-fcfdailyline20 yearsno (line)
EV/Assetsev-assetsdailyline20 yearsno (line)
Earnings Yieldearnings-yielddailyline20 yearsno (line)
FCF Yieldfcf-yielddailyline20 yearsno (line)
EBITDA Yieldebitda-yielddailyline20 yearsno (line)
OCF Yieldocf-yielddailyline20 yearsno (line)
Dividend Yielddividend-yieldmonthlyline20 yearsno (line)
Total Returntotal-returndailyline20 yearsno (line)
ROICroicannualbars10 yearsyes
Revenue (TTM)revenue-ttmttmbars3 yearsyes
Net Income (TTM)net-income-ttmttmbars3 yearsyes
Free Cash Flow (TTM)fcf-ttmttmbars3 yearsyes
EBITDA (TTM)ebitda-ttmttmbars3 yearsyes
Capital Expenditure (TTM)capex-ttmttmbars3 yearsyes
Buybacks (TTM)buybacks-ttmttmbars3 yearsyes
Stock-Based Compensation (TTM)sbc-ttmttmbars3 yearsyes
R&D Expense (TTM)rd-ttmttmbars3 yearsyes
Gross Margin (Quarterly)gross-margin-quarterlyquarterlybars3 yearsyes
Operating Margin (Quarterly)operating-margin-quarterlyquarterlybars3 yearsyes
Net Margin (Quarterly)net-margin-quarterlyquarterlybars3 yearsyes
Revenuerevenueannualbars10 yearsyes
Net Incomenet-incomeannualbars10 yearsyes
EPSepsannualbars10 yearsyes
Free Cash Flowfree-cash-flowannualbars10 yearsyes
EBITDAebitdaannualbars10 yearsyes
Capital Expenditurecapexannualbars10 yearsyes
Buybacksbuybacksannualbars10 yearsyes
Stock-Based Compensationstock-based-compannualbars10 yearsyes
R&D Expenser-and-dannualbars10 yearsyes
Gross Margingross-marginannualbars10 yearsyes
Operating Marginoperating-marginannualbars10 yearsyes
Profit Marginprofit-marginannualbars10 yearsyes
Return on Equityroeannualbars10 yearsyes
Return on Assetsroaannualbars10 yearsyes
Revenue (Quarterly)revenue-quarterlyquarterlybars3 yearsyes
Net Income (Quarterly)net-income-quarterlyquarterlybars3 yearsyes
EPS (Quarterly)eps-quarterlyquarterlybars3 yearsyes
Free Cash Flow (Quarterly)fcf-quarterlyquarterlybars3 yearsyes

Caching

PNG responses carry Cache-Control: public, max-age=3600, s-maxage=21600, stale-while-revalidate=86400, so a URL that has been requested once is served from the edge; the render refreshes with the daily data update. Do not cache-bust the URL — the same URL is the point.

Render limit

Keyless callers may start up to 30 new (uncached) renders per minute per IP address; cached URLs are not counted. Past the limit the endpoint answers 429 with Retry-After: 60 and the body below. A keyed request is exempt from this limiter and metered at 5 units per render against the account's tier quota instead — see authentication and limits.

429 — keyless render limit
{
  "error": "Render rate limit reached — cached chart URLs are unlimited; new renders are capped per minute. API keys lift this to tier quotas: https://tgmcharts.com/developers/keys",
  "upgradeUrl": "https://tgmcharts.com/developers/keys",
  "docs": "https://tgmcharts.com/developers/docs/authentication-and-limits"
}

Errors

  • 400 — unknown query key, out-of-range years, compare on a line metric, or compare equal to the primary symbol.
  • 404 — symbol not covered (onboarding hint), or a slug outside the chart tier (the body lists every chartMetrics slug).
  • Error bodies are JSON; only successful renders are image/png.

FAQ

Can I embed the chart image in a README, newsletter or app?
Yes. The URL is the image: put it in an <img> tag or a Markdown image. The frame carries the TGMCharts attribution and the data-as-of date, which satisfies the attribution requirement of the API terms. Keep the frame intact.
How often do chart images update?
With the daily data refresh after the US market close. The edge caches a rendered URL for six hours and serves it stale for up to a day while it re-renders, so an embedded chart follows the data within a day.
Can I remove the TGMCharts wordmark from the chart?
No. The wordmark and as-of footer are the attribution the API terms require, and no parameter hides them.