Page MenuHomePhabricator

Create an MVP data product of API requests
Open, In Progress, HighPublic

Description

Background

In WE5, Product Analytics needs to be able to analyze API request logs and ultimately produce the API Analytics Dashboard, allowing API user segmentation and compliance to the User-Agent policy to be tracked over time. Another possible byproduct of this data is a pipeline for lead generation for Wikimedia Enterprise.

@KCVelaga_WMF has a series of notebooks which prototype logic for:

  • Identifying and extracting API requests from webrequest
  • Labeling requests using IP provenance
  • Segmenting requests based on User-Agent string
  • Pre-aggregate and compute certain metrics for WE5

On the Data Engineering side, we're interested in establishing patterns for how this analysis can be simpler without having to resort to working directly with webrequest, while striking a pragmatic balance between (1) separating data ingestion from business logic, (2) facilitating common operations and logic changes, and (3) producing a reusable data product for multiple domains.

@KCVelaga_WMF, @JAllemandou and I met this week and agreed that a good solution would be to provide a table of API requests, filtered down from webrequest, and populated with a few fields of general interest; we hope this will enable KC to build downstream datasets, private to Product Analytics at first, to feed into the API Analytics dashboard, future ad-hoc analysis, and eventual standardization.

Essentially, this is pageview_actor, but for API requests.

Acceptance Criteria

This is mostly a paraphrase of Joseph's scoping in the above linked document (thanks!)

  • webrequest is extended with is_api: boolean and api_endpoint: boolean attributes, which will allow a consistent definition of API requests for any downstream data products.
  • webrequest also includes IP provenance information as an ip_provenance: string column.
    • For this MVP, we use the existing GetNetworkOrigin UDF to populate it with wikimedia, wikimedia_labs, and internet labels.
    • As a next step after this MVP, we will integrate the work in T418466 to offer richer, freshly updated labels.
  • An apirequest table is created by filtering webrequest based on the new boolean fields, containing all top-level columns in webrequest, and unpacking four x_analytics fields for ease of discovrey and analysis:
    • x_analytics[‘trusted_req’]
    • x_analytics[‘x_is_browser’]
    • x_analytics[‘rl_class’]
    • x_analytics[‘auth_type’]

Details

Event Timeline

KCVelaga_WMF added a subscriber: amastilovic.

As per discussions, I will be taking this up with DPE support (from @amastilovic).

Change #1288444 had a related patch set uploaded (by KCVelaga; author: KCVelaga):

[analytics/refinery@master] Determine API requests in webrequest refine job

https://gerrit.wikimedia.org/r/1288444

KCVelaga_WMF changed the task status from Open to In Progress.May 19 2026, 7:54 AM
KCVelaga_WMF triaged this task as High priority.
KCVelaga_WMF moved this task from Next 2 weeks to Doing on the Product-Analytics (Kanban) board.

Change #1288444 merged by Joal:

[analytics/refinery@master] Determine API requests in webrequest refine job

https://gerrit.wikimedia.org/r/1288444

Change #1297686 had a related patch set uploaded (by KCVelaga; author: KCVelaga):

[analytics/refinery@master] User-Agent compliance and API requests refinement HQLs

https://gerrit.wikimedia.org/r/1297686