Skip to content

Category API #6

Closed
Closed
@rviscomi

Description

@rviscomi

For feature parity in v1 we'll also need an API to list all of the technologies for each category.

You can see how it works in the existing dashboard:

image

Enter a category name

image

The Technology dropdown updates to display only the technologies of the filtered category

The shape of the API should be an object where the keys are category names and the values are arrays of technologies sorted by popularity:

{
  "Most popular category by total number of origins": [
    "Most popular technology in the category",
    "Second most popular technology",
    "..."
  ],
  "Second most popular category": [
    "..."
  ]
}

Here's an example query to extract the categories:

WITH categories AS (
  SELECT
    category,
    COUNT(DISTINCT root_page) AS origins
  FROM
    `httparchive.all.pages`,
    UNNEST(technologies) AS t,
    UNNEST(t.categories) AS category
  WHERE
    date = '2023-08-01' AND
    client = 'mobile'
  GROUP BY
    category
),

technologies AS (
  SELECT
    category,
    technology,
    COUNT(DISTINCT root_page) AS origins
  FROM
    `httparchive.all.pages`,
    UNNEST(technologies) AS t,
    UNNEST(t.categories) AS category
  WHERE
    date = '2023-08-01' AND
    client = 'mobile'
  GROUP BY
    category,
    technology
)


SELECT
  category,
  categories.origins,
  ARRAY_AGG(technology ORDER BY technologies.origins DESC) AS technologies
FROM
  categories
JOIN
  technologies
USING
  (category)
GROUP BY
  category,
  categories.origins
ORDER BY
  categories.origins DESC

I've formatted the output and saved the results to a static file: https://github.com/HTTPArchive/tech-report-apis/blob/main/static/categories.json

Also available via the CDN: https://cdn.httparchive.org/reports/cwvtech/categories.json

cc @sarahfossheim

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions