Skip to content

feat: add /v1/geo-breakdown endpoint for geographic CWV breakdown#94

Merged
max-ostapenko merged 4 commits intoHTTPArchive:developmentfrom
alonkochba:feature/geo-breakdown-endpoint
Mar 23, 2026
Merged

feat: add /v1/geo-breakdown endpoint for geographic CWV breakdown#94
max-ostapenko merged 4 commits intoHTTPArchive:developmentfrom
alonkochba:feature/geo-breakdown-endpoint

Conversation

@alonkochba
Copy link
Copy Markdown
Member

Companion to HTTPArchive/httparchive.org#1220, implementing HTTPArchive/httparchive.org#1146.

Summary

Adds a new /v1/geo-breakdown endpoint that returns Core Web Vitals data for all geographies for a given technology. Unlike /v1/cwv, this endpoint omits the geo filter so callers can build a geographic breakdown chart without issuing one request per country.

Changes

  • src/controllers/geoBreakdownController.js — new controller; queries core_web_vitals without a geo filter, includes geo in the field projection
  • src/index.js — wires up GET /v1/geo-breakdown

API

GET /v1/geo-breakdown?technology=Wix&rank=ALL&start=latest

Parameters mirror /v1/cwv except geo is not accepted (all geographies are returned):

Param Default Description
technology ALL Technology name(s), comma-separated
rank ALL Rank filter
start Date range start (YYYY-MM-DD or latest)
end Date range end (YYYY-MM-DD)

Response format is identical to /v1/cwv with an additional geo field per record.

Adds a new controller and route that returns core_web_vitals data for
all geographies for a given technology. Unlike /cwv, this endpoint omits
the geo filter so callers can build a geographic breakdown chart without
issuing one request per country.
@tunetheweb
Copy link
Copy Markdown
Member

@max-ostapenko could you give you opinion on this before @alonkochba takes it much further?

I like the idea, and landing the API first will allow the front-end changes to be tested.

Questions I have are:

  • Code - looks fine to me from a quick glance but I don't know this well enough!
  • Test cases?
  • Any capacity concerns? We already get a lot of 403s from these APIs (especially on CrUX release day - presumably cause a lot of people hit it at once?) so adding to that wouldn't be great. Though I think this should only be called on a single technology page, rather than the comparison screens (would be too noisy there!) so maybe that's not as big a concern after all because of that?

* Query params:
* technology (required)
* rank (default: ALL)
* start (optional; 'latest' resolves to the most recent date)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it doesn’t make sense to support this. It should be according to a single month of data and not multiple months probably.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on your visualization example it seems that a single monthly snapshot is sufficient.
1 month of CWV data is 15Kb btw.

@max-ostapenko
Copy link
Copy Markdown
Contributor

max-ostapenko commented Mar 11, 2026

@alonkochba let's add the cross-geo implementation to the existing createReportController.

Define and verify the parameter combinations definition (in order to have a bounded set of results):

  1. metric time series (current behaviour): technology + geo + rank are required
  2. cross-geo snapshot: technology + rank + start date + end date (point-in-time) are required

This will allow to later extend the visualization with any of the existing metrics.

@max-ostapenko
Copy link
Copy Markdown
Contributor

All data required is already available in database, so it's a matter of adding an endpoint.

Screenshot 2026-03-11 at 22 22 20

@alonkochba
Copy link
Copy Markdown
Member Author

Thanks, updating. Is it really a good idea to make start/end required though? and the default is usually 7 years of data (start is 2020, end is latest), seems like a waste to serve this API for all period for now if we only display last month

Updated suggestion to only use end date (or latest if not given) for now wdyt?

Add crossGeo option to createReportController; delete standalone
geoBreakdownController.js. Endpoint now returns a single-month snapshot
(latest by default, or the month specified by the end param).
@alonkochba alonkochba marked this pull request as ready for review March 15, 2026 14:55
@alonkochba alonkochba changed the title WIP: feat: add /v1/geo-breakdown endpoint for geographic CWV breakdown feat: add /v1/geo-breakdown endpoint for geographic CWV breakdown Mar 17, 2026
@max-ostapenko max-ostapenko changed the base branch from main to development March 23, 2026 08:39
@max-ostapenko max-ostapenko merged commit 724a126 into HTTPArchive:development Mar 23, 2026
max-ostapenko added a commit that referenced this pull request Mar 23, 2026
* feat: add /v1/geo-breakdown endpoint for geographic CWV breakdown (#94)

* feat: add /v1/geo-breakdown endpoint for geographic CWV breakdown

Adds a new controller and route that returns core_web_vitals data for
all geographies for a given technology. Unlike /cwv, this endpoint omits
the geo filter so callers can build a geographic breakdown chart without
issuing one request per country.

* refactor: merge geo-breakdown into reportController factory

Add crossGeo option to createReportController; delete standalone
geoBreakdownController.js. Endpoint now returns a single-month snapshot
(latest by default, or the month specified by the end param).

---------

Co-authored-by: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>

* test: add tests for /v1/geo-breakdown

---------

Co-authored-by: Alon Kochba <alonko@wix.com>
max-ostapenko added a commit that referenced this pull request Mar 24, 2026
* feat: add /v1/geo-breakdown endpoint for geographic CWV breakdown (#94)

* feat: add /v1/geo-breakdown endpoint for geographic CWV breakdown

Adds a new controller and route that returns core_web_vitals data for
all geographies for a given technology. Unlike /cwv, this endpoint omits
the geo filter so callers can build a geographic breakdown chart without
issuing one request per country.

* refactor: merge geo-breakdown into reportController factory

Add crossGeo option to createReportController; delete standalone
geoBreakdownController.js. Endpoint now returns a single-month snapshot
(latest by default, or the month specified by the end param).

---------

Co-authored-by: Max Ostapenko <1611259+max-ostapenko@users.noreply.github.com>

* test: add tests for /v1/geo-breakdown

* fix: update CDN cache duration in setCommonHeaders function

* fix: update CDN cache tag and duration in response headers

* feat: add ETag support for caching in report responses

* test: add ETag header tests for /v1/technologies and /v1/adoption routes

---------

Co-authored-by: Alon Kochba <alonko@wix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants