First data on screen, and the meter that shows what it cost
By the end of this lesson you will have three instruments on screen with the usage meter beside them, first on fixtures and then on your own account, and the measured number of calls one page view costs you.
Time to see something real. Your own instruments go on screen with live-ish prices, and beside them a number most tutorials never show you: how much of today's allowance you just spent.
One request for the whole list
The naive watchlist fetches each ticker separately: twelve instruments, twelve calls. The real endpoint takes the first ticker in the path and the rest in s:
/real-time/AAPL.US?s=MSFT.US
Captured live on 2026-08-25, that returns both instruments in one response:
[{"code":"AAPL.US","timestamp":1787603280,"open":311.47,"high":313.36,"low":309.97,
"close":310.34,"volume":32510925,"previousClose":309.35,"change":0.99,"change_p":0.32},
{"code":"MSFT.US","timestamp":1787603220,"open":483.205,"high":490.605,"low":481.86,
"close":487.31,"volume":15668481,"previousClose":483.24,"change":4.07,"change_p":0.8422}]
Everything a watchlist row needs is there: close is the current price, change and change_p are the move since previousClose, and timestamp is when the exchange produced it.
The trap, and it is a real one: with one ticker and no s parameter the endpoint returns a bare object, not an array of one. Code written against two tickers works fine and breaks the day someone trims the list to one. Handle both shapes from the start:
const body = await res.json();
const rows = Array.isArray(body) ? body : [body];
This is the kind of thing an assistant gets wrong when it is guessing and right when it is wired to the real API — the point of the previous lesson.
The number nobody shows you
Every plan has a daily call allowance. Most tutorials pretend it does not exist, so you meet it for the first time when your tool stops working on a morning you needed it.
The account endpoint tells you where you stand:
/user
It returns your plan, how many calls you have made today, and your limit — alongside your email, your payment method and an invite token. Surface only the three meter fields. Your watchlist has no business rendering your email address, and a /api/usage route that forwards the whole object is a small leak waiting to be screenshotted.
return Response.json({
plan: u.subscriptionType,
used: u.apiRequests,
dailyLimit: u.dailyRateLimit,
});
Put that on screen from day one, not as decoration but as instrumentation. Two things become visible immediately: what a page view actually costs you, and how expensive a page that refreshes every five seconds turns out to be.
Requests are not calls
This distinction is the one that decides whether your arithmetic is right, and the API's own limits page states it plainly: "An API request is not the same as an API call; API calls are a form of 'currency' used to make requests."
A request is one HTTP round trip. A call is what it costs. Measured against the live API on 2026-08-26:
| Endpoint | Calls per request |
|---|---|
/user |
0 — the meter is free |
/eod, /div, /splits, /exchange-symbol-list |
1, whatever the row count |
/real-time |
1 per symbol — a ten-symbol request costs ten |
/screener, /technical, intraday |
5 |
/news |
5 per ticker — two tickers in s cost ten |
/fundamentals, options, bond fundamentals |
10 |
Read the second and third rows together: forty-five years of daily bars is one call, on a plan that reaches that far back (the free plan stops at one year), while ten live quotes is ten — whether you ask in ten requests or in one. And a request for a ticker that does not exist still costs its price: a typo is not free.
The starter keeps this table in src/lib/cost.ts, with estimateCalls() to price
a request before it is sent. Measure the ones you use rather than trusting either
copy. Pricing changes, and a table in a lesson goes stale.
So a watchlist costs length × reloads. Both axes are real, and the next lesson is about the one most people get wrong.
Say how old the number is
A price with no timestamp is a price you cannot trust. The response carries one, so use it: compute the age and print it.
Data age: 3 min old · 09:48 UTC
Read it from the response's own timestamp rather than from your plan's name. The plan name is a claim about what you should be getting; the timestamp is evidence about what you got. Those two disagree more often than you would like — a market can be closed, a feed can lag — and only one of them is checkable.
This small habit is what makes unit 4 honest. When you meet the freshness wall, you will not be told about it in a sales panel; you will read it off your own screen.
Mock first, then your own data
Everything so far can run without a key. Put EODHD_MOCK=1 in .env.local, restart the dev server, and the proxy answers from the JSON files in fixtures/: real response shapes, zero calls, and a line at the top of the page saying it is mock data. That is where you and your agent iterate — rule 4 of the house rules — because an agent that reloads the page thirty times while fixing a layout would otherwise spend thirty page views of your allowance on nothing. You set the switch, not the agent: .env.local is one of the files it is not allowed to touch.
When the mock version works, switch. Get a free key (if you did Pair With Your Agent you already have one: see "Your free key, and .env.local" in MCP while you build, the API while it runs, one budget for both; otherwise register at eodhd.com/register, confirm your email, log in, and copy the API token your dashboard shows), put it on the EODHD_API_KEY= line of .env.local (copy .env.example to .env.local first if the file does not exist), restart without EODHD_MOCK, and the numbers on your screen become your numbers, drawn against your allowance. Mock data is for building; the meter only means something on the real thing. From here to the end of the course you check every feature against your own account — including, in unit 4, its limits.
Try it now
The prompt
Put EODHD_MOCK=1 in .env.local and restart the dev server. Start the agent in the starter folder and paste:
Mock mode is on. Trim WATCHLIST in src/lib/watchlist.ts to three of the
five tickers already in it; ask me which three. Before you edit, tell
me what one page load will cost live, using pageLoadCalls() in
src/lib/quotes.ts, and what ten reloads would cost against the free
plan's 20 calls a day. If a comment in that file says how many tickers
or calls there are, make it true. Change no other file. Run npm test
and show me the diff.
A good answer asks which three, says three calls a load and thirty for ten reloads — more than a free day — and changes one file, src/lib/watchlist.ts. Your own instruments, if they differ from the five, come in lesson 8, "Your tickers, in one request"; for now choose from the five. If your PLAN.md names more instruments than three, add "three for now" next to them in your editor, so the plan and the code agree.
Check it yourself
- In mock mode the page shows three rows, the mock-mode notice on top, and under the meter: "This load cost nothing. Live, it would cost 3 calls."
- The usage route, at
/api/usageon the addressnpm run devprints (usuallyhttp://localhost:3000/api/usage; if that port was busy it chose 3001), answers from the fixtures and costs nothing:{"plan":"free","used":0,"dailyLimit":20,"remaining":20,"pageLoadCalls":3,"mock":true} - Now go live: put your key in
.env.local, removeEODHD_MOCK, restart. (Thedemotoken shows prices for a handful of symbols, but its counter belongs to everybody, so you cannot measure your own usage with it: for this step and step 4 you need a key of your own.) Before the first load, say the price out loud — three calls. The page shows your three instruments with real prices, and the meter your plan and today's count. - Read the usage route, reload the page three times, wait a few seconds — the counter lags behind the requests — and read it again.
usedhas risen by nine: three calls a page view. Not ten reloads: on a free plan that is thirty calls against a day of twenty (a new account's one-time bonus of 500 calls is drawn on after the twenty, so the 402 can be weeks away, but plan with the twenty). Write the per-view figure down: it decides whether your tool can refresh every minute or only every hour, and unit 4 needs it. Without a key of your own yet, stop after step 2: the mock line "Live, it would cost 3 calls" is the figure to write down, marked as an estimate.
Break it on purpose
Make the Checkpoint commit below first, so git has a copy to restore. Back in mock mode, trim the list to one ticker, and in quotes() replace const rows: RawQuote[] = Array.isArray(body) ? body : [body as RawQuote]; with const rows = body as RawQuote[];. Reload. With one ticker the endpoint answers a bare object, the code calls filter on it, and the page reports that the call did not return data: a valid key and a good ticker, reported as a failure. Restore both files with git restore src/lib/quotes.ts src/lib/watchlist.ts.
Compare with ours
Our change
| File | What changed |
|---|---|
src/lib/watchlist.ts |
five tickers down to three: AAPL.US, MSFT.US, SPY.US |
Nothing else. The meter, the usage route and the cost line under the meter ship with the starter; this lesson is about reading them. The full state at the end of this unit is on the starter's branch ref/build-your-first-tool/u1.
Checkpoint
git status # only the files you expect, and no .env*
git add -A
git commit -m "Three instruments to start with, so the meter reads three calls a load"
Then answer this lesson's questions.