Closed alekseykulikov closed 4 years ago
It's possible to use googleapis to request CrUX API.
googleapis
A basic example:
// run: CRUX_KEY='...' node ./crux-with-googleapis.js import { google } from 'googleapis' const key = process.env.CRUX_KEY || 'no-key' const crux = google.chromeuxreport('v1') crux.records .queryRecord({ auth: key, // authentication key requestBody: { origin: 'https://example.com' } // queryRecord params }) .then((r) => { // r.data contains success/error response console.log(JSON.stringify(r.data, null, ' ')) }, console.error)
How is crux-api different from googleapis? Pros:
crux-api
Cons:
It's possible to use
googleapis
to request CrUX API.A basic example:
How is
crux-api
different fromgoogleapis
? Pros:crux-api
is 3200x smaller)Cons:
googleapis
);