Every time I bolt a new data source onto my stack, the same class of failure shows up, and it showed up again with Finnhub: a 403 on /stock/candle. I have a page of self-hosting security notes that exists partly because I keep learning this kind of lesson the hard way — the lesson that an error code is often a message from a provider’s business model, not from my own code. This is the write-up of that specific 403: what I was building, why I spent far too long convinced the bug was mine, how I finally proved it wasn’t, and what I changed in how I evaluate any free API tier before I build on top of it.
The project that needed candles
The need was small and boring, which is exactly why it caught me. I wanted daily OHLCV history — open, high, low, close, volume — for a little paper-trading side project. Not tick data, not order books, not a streaming feed. Just the end-of-day bars that every chart on the internet is drawn from. OHLCV is the substrate for basically any backtest or signal toy: you load bars into a table, you compute something over a window, you print a number and feel clever.
I picked Finnhub for the usual lazy reasons. It advertises a free tier, it hands you a single API key instead of an OAuth dance, and the documentation presents one coherent surface — one place to look, one set of endpoint names, one response shape. When you’re wiring a hobby project at the end of the day, “one key, one base URL, docs that look complete” is worth more than any comparison table. I signed up, took the key, dropped it into the environment of the ingest script, and started building.
This is the part I want to be honest about: I did not read the pricing page first. I read the endpoint documentation, which is the page that tells you how to call things, not the page that tells you whether you’re allowed to. Those are two different documents, and the gap between them is where this whole post lives.
What broke
The first thing I did was the thing everyone does: a smoke test. I exercised the parts of the API I touched first, and they answered normally. Keys resolved, responses parsed, the client code looked correct because it produced correct-looking output. That is the trap, and I want to underline it, because it is the reason I lost time. A smoke test that only touches the endpoints you happened to try first does not validate the endpoint you actually need. It validates your willingness to feel good about progress.
Then I wired in the candle call — the one the entire project depends on — and got a 403. The response body told me nothing useful. There was no stack trace on my side, no parse error, no timeout. Just a refusal, on exactly one path, while everything around it behaved. The status code was the only real signal in the whole exchange.
GET /stock/candle
403 Forbidden
My first reaction was not “the provider wants money.” My first reaction was “what did I break.” I think that reaction is almost universal among people who write their own clients, and it is worth naming, because it is a bias and not a diagnosis: when you are the author of the code making the request, a rejection reads as a bug in your authorship. The provider is a black box that presumably works. You are the variable. So you start debugging the variable.
Why a 403 feels like your fault
Permission errors are, in most of the systems I run, things I control. File modes. Service accounts. Reverse-proxy rules. When I get a “forbidden” from something inside my own lab, it is nearly always a misconfiguration on my end, and the fix is a line in a config file. That instinct transfers badly to third-party APIs, where “forbidden” frequently means “forbidden to you, by policy, on purpose.”
So I went down the list of things that would be my fault, in roughly the order a tired person goes down them:
- The key isn’t reaching the request. Maybe the environment variable isn’t exported where the script runs, or the client is silently sending an empty credential. If that were true, the request would be anonymous — and anonymous requests were behaving differently from what I was seeing. Ruled out.
- The key is wrong or disabled. A bad credential produces an authentication complaint, and it would fail on every call, not one path. Every other endpoint I touched was fine. The credential was valid, accepted, and understood. Ruled out.
- The request is malformed. Wrong parameter names, bad date format, missing interval. I narrowed the parameter set, simplified it, and the result didn’t move. A malformed request tends to produce a complaint about the shape of the request. I got a flat refusal instead. Ruled out.
- The symbol is the problem. Maybe this particular ticker isn’t covered, or the free tier only covers some exchanges. I changed the symbol. Same 403. The refusal wasn’t attached to the data I asked for. Ruled out.
- My client is doing something weird. Proxies, retries, header rewriting, a middleware layer I forgot about. I reproduced the call outside my own code, with nothing but the path and the key, and got the same answer. Ruled out.
That last step is the one that flips the whole thing. Once the identical request fails from a completely different client, with no shared code, the only remaining variable is the endpoint itself. And the endpoint is not mine.
The distinction that ended the debugging session
Here is the sentence I wish I had said to myself at the start: a 403 on exactly one endpoint, while every adjacent endpoint answers, is a scope statement.
It is the API saying three things at once. First, the path is real — I’m not hitting a typo’d URL, because an unknown route fails differently. Second, it knows who I am — the credential was accepted, otherwise the complaint would be about authentication, not permission. Third, and this is the important one, it has decided that this identity may not have this resource. That’s not a bug report. That’s a price list.
The trap is that all three of those facts arrive as a single opaque word. “Forbidden” reads like “you did something wrong,” when in this case it meant “you did everything right and you’re on the wrong plan.” There is no error text in the world that says “upgrade to continue,” because that would be rude; instead you get a status code and a body that says nothing, and the business model is implied.
The line I should have read first
When I finally went looking properly, the answer was sitting in plain sight on the pricing and plan documentation: the free tier covers a subset of the API, and candle history is not in that subset. The documentation wasn’t lying. It documented the whole product honestly, because documenting the whole product is how you sell the whole product. The boundary between “free” and “paid” lives in a table on a different page, and nothing in the quickstart forces you to walk past it.
That is what “silently limited” means in practice. Nothing errors at signup. Nothing warns you when you generate a key. The limit isn’t silent because it’s hidden — it’s silent because it’s expressed in a form you weren’t reading. You find it at request time, which is the most expensive possible moment to find it, because by then you have written code against the shape of an answer that will never come.
The fix: an adapter, not a rewrite
The good news is that my need was genuinely generic. Daily OHLCV bars are the most commoditised data in finance; dozens of providers will hand you the same six columns in slightly different JSON. Yahoo Finance serves that same OHLCV history, and it did not answer with a 403.
What I refused to do was rewrite the ingest code around a second vendor’s response shape. That’s the move that turns one afternoon of provider shopping into a week of refactoring, and then again next time. Instead I put the fetch behind a single seam — one function, one contract: give me a symbol and a date range, give me back a list of bars. Everything downstream of that function sees bars and does not know or care who produced them.
fetch_bars(symbol, start, end) -> [ {open, high, low, close, volume}, ... ]
provider = finnhub -> 403 on /stock/candle (free tier: endpoint not included)
provider = yahoo -> returns OHLCV history
caller: unchanged
Swapping the implementation was a one-line decision at the call site. The parsing, the storage, the window maths, the reporting — none of it moved. That seam is also the thing that makes the eventual decision cheap: if I ever decide the extra data quality or reliability of a paid tier is worth it, I put the original implementation back and the rest of the system never learns about it. An adapter is not architecture astronautics. It’s the difference between a provider choice costing one line and costing a refactor.
The trade-off I accepted, and I want to state it plainly rather than pretend the substitute is strictly better: Yahoo Finance is not a contract. It’s an interface that isn’t promised to me, it can change shape, and it can rate-limit or block without warning. A commercial API with a paid tier is a stronger promise than a public endpoint that happens to work. So the adapter isn’t just convenience — it’s insurance in both directions. It let me leave a provider that gated the endpoint I needed, and it lets me leave a provider that stops being convenient. I wrote down, next to the implementation, exactly what it depends on, so that the next person to touch it — usually me, months later, having forgotten everything — knows what the risk is.
The general shape of this trap
Free tiers are almost never “the API, free.” They are a slice of the API, free, with the boundary drawn where it’s commercially convenient and documented where it’s least disruptive to the sales page. The gating happens in more forms than one, and the 403-on-candles is only the bluntest:
- Endpoint gating. The one you need is simply not in the plan. This is the version I hit, and it’s the easiest to diagnose once you stop suspecting yourself.
- Depth gating. The endpoint works, but history stops at some window, so your backtest quietly starts later than you think it does.
- Volume gating. It works until you exceed some request budget, and then the failures look like flaky infrastructure rather than a plan limit.
- Field gating. The call succeeds and returns a well-formed object with the interesting fields empty. This is the worst one, because there is no error at all — just a null where a number should be, and a pipeline that runs happily on nothing.
Every one of those shapes punishes the same habit: building against the documentation of the product instead of against the reality of your plan. And every one of them is cheap to discover on day zero and expensive to discover on day three.
The test I run now, before writing any client
This is the part that actually changed. It costs minutes and it has saved me from repeating the whole episode.
- Write the list, not the category. Not “market data” — the exact endpoints, and the exact fields inside each response, that the project cannot function without. Be brutally literal. If you can’t write the list, you don’t know what you’re building on yet.
- Read the plan against the list. Not against the feature page — against your list. Scan the pricing table for the specific names you wrote down. If a name isn’t there, assume it’s gated until proven otherwise.
- Hit every endpoint on the list once, with real parameters, before writing parsing code. Not the easy ones. The list. Real symbols, real date ranges, real page sizes — the parameters production will use, not a hello-world query.
- Record what came back. Status and body, for each one, in a note next to the project. This takes a moment and becomes the ground truth you consult instead of guessing at a 403 later.
- Treat a 403 at this stage as a pricing answer, not a puzzle. If the endpoint is gated, you’ve learned it before a single line of client code exists. That’s the cheapest possible version of this lesson. Take it and move on.
Step three is the one I skipped, and it’s the one that matters. My smoke test proved the API was reachable and my key was live. It proved nothing about the call the project was built on. A test that doesn’t include the critical path is not a test of the critical path — it’s a test of your optimism.
What I’d do differently
Beyond the checklist, three habits earned their place:
- Distrust my own guilt reflex. When a third-party API rejects me, the first hypothesis should not be “I wrote it wrong.” It should be “what is this rejection actually about?” Permission on one endpoint, with everything else healthy, is a policy statement. Check the policy before you check your headers.
- Never put an external provider’s response shape directly into business logic. One function, one contract, one place to swap. It costs a few lines at the start and saves a rewrite later, and the rewrite is the thing that always arrives at the worst time.
- Keep a per-provider note: what’s free, what’s gated, what the fallback is. Not a wiki, not a research project — three lines next to the code. My future self has no memory of this afternoon, and the note is the only thing that will stop him from re-deriving it from a 403.
The outcome
The pipeline runs. It fetches daily OHLCV bars from a provider that serves them, stores them, and computes the same numbers it was always going to compute. The candle endpoint on the original service still returns a 403, and it will keep returning a 403 until I pay for a plan that includes it. That’s not a defect to be fixed — that’s a decision I made with the information I now have, which is exactly what it should be.
The annoying part is that the thing which broke was never broken. There was no bug. My client was correct, my key was valid, my parameters were fine, and the request did exactly what the provider intended from the moment it left my machine. The only mistake was mine, and it happened before any code was written: I assumed that an API’s documentation and an API’s availability to me were the same document. They aren’t. They never are.
The rule I kept
A 403 is a price tag wearing an error code. When you get one on precisely the endpoint your project needs, while everything around it answers, stop reading your own code and start reading the plan. Then, if the answer is money, believe it, route around it, and put the next provider behind a seam so the decision stays cheap. The bug was never in my code — and the fix wasn’t in it either. It was in the order I did things: test the exact endpoint you need, with the exact parameters you’ll use, before you build anything on top of it.
Related
- Docker’s FORWARD DROP Ate My Container-to-Host Traffic
- Docker Compose .env Changes Need Container Recreation
- systemctl –user Fails as Root: “No Medium Found”
- Fixing ECONNRESET on a Self-Hosted HTTP Bridge
- Deploy n8n Workflows via CLI, Not SQLite
Guides & explainers
Filed under: Home Lab, Home Lab, Self-Hosting