Case study
Serving 53 countries inside a fixed API quota
TrendingZ was re-architected so that scheduled background jobs fetch the charts and visitors read them from storage. Every YouTube call goes through one quota ledger with reserved budgets, so the audience no longer depends on the daily quota.


Context
Where this started.
Context
TrendingZ shows trending YouTube videos and Shorts for 53 countries.
Problem
The YouTube Data API gives 10,000 units a day for the whole project. With calls made on behalf of visitors, the quota set a ceiling on how many people could use the product, and running out left the site blank.
Approach
What was done.
Who asks
- Chart sweeps: Tiered schedule
- Genre enrichment: Daily
- Visitor request: Search miss, stale
- Every page view: Read only
Ledger
- Quota ledger: 10,000 units a day
Source
- YouTube Data API: v3
Storage
- MongoDB: Charts, snapshots
Connections
- Chart sweeps → Quota ledger: 3,000-unit budget
- Genre enrichment → Quota ledger: 4,500-unit budget
- Visitor request → Quota ledger: 2,000-unit budget
- Quota ledger → YouTube Data API: Only within budget
- YouTube Data API → MongoDB: Stored as returned
- Every page view → MongoDB: Served from storage
- 01
Background jobs fetch, visitors read
Scheduled sweeps write charts into MongoDB, stored exactly as YouTube returns them. The request path reads storage, so serving from storage runs the same code as serving from YouTube.
- 02
Tiered sweeps
Three regions hourly at full depth, twelve every six hours, the rest daily: about 1,600 units a day instead of about 51,000.
- 03
One ledger, three budgets
Every call asks a shared ledger first. Chart sweeps have 3,000 units, genre enrichment 4,500 and visitor-triggered calls 2,000, so visitors can never eat the budget the charts depend on.
- 04
Snapshots and graceful staleness
Each sweep stores a snapshot, which powers Rising Now at no API cost. When fresh data cannot be fetched, a chart up to 72 hours old is shown with a notice.
Outcome
The result.
API spend is fixed by the schedule, not by traffic: chart sweeps cost about 1,600 units a day, and the visitor budget is capped at 2,000. Traffic figures are not published.
- countries
- 53
- units a day for chart sweeps
- ~1,600
- unit cap on visitor-triggered calls
- 2,000
For you
What a similar client would get.
- A product built on a metered API whose cost no longer grows with traffic.
- Budgets that protect the work your product depends on from user-triggered spend.
- Pages that show labelled older data instead of failing when a source is down.
Technology
What it was built with.
Facing a similar problem?
Tell us what you are working on. A person from Dessot will reply.

