chrome-ux-report

CrUX API - 404 NOT_FOUND for valid domains


CrUX Demo Code - giving a 404 for major public sites?

I'm trying to run the sample code from Google's CrUX API docs page. The code:

const CrUXApiUtil = {};
// Get your CrUX API key at https://goo.gle/crux-api-key.
CrUXApiUtil.API_KEY = 'MY_KEY_REDACTED';
CrUXApiUtil.API_ENDPOINT = `https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=${CrUXApiUtil.API_KEY}`;
CrUXApiUtil.query = function (requestBody) {
  if (CrUXApiUtil.API_KEY == '[YOUR_API_KEY]') {
    throw 'Replace "YOUR_API_KEY" with your private CrUX API key. Get a key at https://goo.gle/crux-api-key.';
  }
  return fetch(CrUXApiUtil.API_ENDPOINT, {
    method: 'POST',
    body: JSON.stringify(requestBody)
  }).then(response => response.json()).then(response => {
    if (response.error) {
      return Promise.reject(response);
    }
    return response;
  });
};

CrUXApiUtil.query({
    origin: 'https://developers.google.com'
  }).then(response => {
    console.log(response);
  }).catch(response => {
    console.error(response);
  });

That produces a good result, as do SOME other origin values for major websites.

The result with data is inconsistent.

It works for facebook.com and web.dev and developers.google.com.

It gives a 404 error for nytimes.com, cleveland.com, ticketmaster.com and several other sites that are not trivially small (including several where I work).

Things I Tried:

I'm guessing I'm either misunderstanding the Cloud API Key setup, or there's a permission in Search Console I can't see or lack as I'm not a full admin in Search Console. (But, for both, why would it work for facebook.com or web.dev as I don't have access to their Search Console....)

Example Error

{
  error: {
    code: 404,
    message: 'chrome ux report data not found',
    status: 'NOT_FOUND'
  }
}

Solution

  • Each origin is treated as unique in CrUX. So example.com, www.example.com, and blog.example.com are all different origins in CrUX. Some of which may be in the CrUX dataset, and some of which may not, depending on whether they are visited by sufficient users.

    Importantly, an origin is not the same as a registrable domain.

    It gives a 404 error for nytimes.com, cleveland.com, ticketmaster.com and several other sites that are not trivially small (including several where I work).

    None of those are websites that serve content - they all redirect to other origins. https://www.nytimes.com, https://www.cleveland.com, and https://www.ticketmaster.com however all return results from CrUX.

    Some CrUX tools like PageSpeed Insights will check for redirects but the API does not (however it will "normalize" the URL to just that origin by removing trailing slashes and paths, for example).