v5.d.ts
22.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
/// <reference types="node" />
import { OAuth2Client, JWT, Compute, UserRefreshClient, BaseExternalAccountClient, GaxiosPromise, GoogleConfigurable, MethodOptions, StreamMethodOptions, GlobalOptions, GoogleAuth, BodyResponseCallback, APIRequestContext } from 'googleapis-common';
import { Readable } from 'stream';
export declare namespace pagespeedonline_v5 {
export interface Options extends GlobalOptions {
version: 'v5';
}
interface StandardParameters {
/**
* Auth client or API Key for the request
*/
auth?: string | OAuth2Client | JWT | Compute | UserRefreshClient | BaseExternalAccountClient | GoogleAuth;
/**
* V1 error format.
*/
'$.xgafv'?: string;
/**
* OAuth access token.
*/
access_token?: string;
/**
* Data format for response.
*/
alt?: string;
/**
* JSONP
*/
callback?: string;
/**
* Selector specifying which fields to include in a partial response.
*/
fields?: string;
/**
* API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
*/
key?: string;
/**
* OAuth 2.0 token for the current user.
*/
oauth_token?: string;
/**
* Returns response with indentations and line breaks.
*/
prettyPrint?: boolean;
/**
* Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
*/
quotaUser?: string;
/**
* Legacy upload protocol for media (e.g. "media", "multipart").
*/
uploadType?: string;
/**
* Upload protocol for media (e.g. "raw", "multipart").
*/
upload_protocol?: string;
}
/**
* PageSpeed Insights API
*
* The PageSpeed Insights API lets you analyze the performance of your website with a simple API. It offers tailored suggestions for how you can optimize your site, and lets you easily integrate PageSpeed Insights analysis into your development tools and workflow.
*
* @example
* ```js
* const {google} = require('googleapis');
* const pagespeedonline = google.pagespeedonline('v5');
* ```
*/
export class Pagespeedonline {
context: APIRequestContext;
pagespeedapi: Resource$Pagespeedapi;
constructor(options: GlobalOptions, google?: GoogleConfigurable);
}
/**
* A light reference to an audit by id, used to group and weight audits in a given category.
*/
export interface Schema$AuditRefs {
/**
* The category group that the audit belongs to (optional).
*/
group?: string | null;
/**
* The audit ref id.
*/
id?: string | null;
/**
* The weight this audit's score has on the overall category score.
*/
weight?: number | null;
}
/**
* A proportion of data in the total distribution, bucketed by a min/max percentage. Each bucket's range is bounded by min <= x < max, In millisecond.
*/
export interface Schema$Bucket {
/**
* Upper bound for a bucket's range.
*/
max?: number | null;
/**
* Lower bound for a bucket's range.
*/
min?: number | null;
/**
* The proportion of data in this bucket.
*/
proportion?: number | null;
}
/**
* The categories in a Lighthouse run.
*/
export interface Schema$Categories {
/**
* The accessibility category, containing all accessibility related audits.
*/
accessibility?: Schema$LighthouseCategoryV5;
/**
* The best practices category, containing all best practices related audits.
*/
'best-practices'?: Schema$LighthouseCategoryV5;
/**
* The performance category, containing all performance related audits.
*/
performance?: Schema$LighthouseCategoryV5;
/**
* The Progressive-Web-App (PWA) category, containing all pwa related audits.
*/
pwa?: Schema$LighthouseCategoryV5;
/**
* The Search-Engine-Optimization (SEO) category, containing all seo related audits.
*/
seo?: Schema$LighthouseCategoryV5;
}
/**
* Message containing a category
*/
export interface Schema$CategoryGroupV5 {
/**
* The description of what the category is grouping
*/
description?: string | null;
/**
* The human readable title of the group
*/
title?: string | null;
}
/**
* Message containing the configuration settings for the Lighthouse run.
*/
export interface Schema$ConfigSettings {
/**
* How Lighthouse was run, e.g. from the Chrome extension or from the npm module.
*/
channel?: string | null;
/**
* The form factor the emulation should use. This field is deprecated, form_factor should be used instead.
*/
emulatedFormFactor?: string | null;
/**
* How Lighthouse should interpret this run in regards to scoring performance metrics and skipping mobile-only tests in desktop.
*/
formFactor?: string | null;
/**
* The locale setting.
*/
locale?: string | null;
/**
* List of categories of audits the run should conduct.
*/
onlyCategories?: any | null;
}
/**
* Message containing environment configuration for a Lighthouse run.
*/
export interface Schema$Environment {
/**
* The benchmark index number that indicates rough device class.
*/
benchmarkIndex?: number | null;
/**
* The user agent string of the version of Chrome used.
*/
hostUserAgent?: string | null;
/**
* The user agent string that was sent over the network.
*/
networkUserAgent?: string | null;
}
/**
* Message containing the i18n data for the LHR - Version 1.
*/
export interface Schema$I18n {
/**
* Internationalized strings that are formatted to the locale in configSettings.
*/
rendererFormattedStrings?: Schema$RendererFormattedStrings;
}
/**
* An audit's result object in a Lighthouse result.
*/
export interface Schema$LighthouseAuditResultV5 {
/**
* The description of the audit.
*/
description?: string | null;
/**
* Freeform details section of the audit.
*/
details?: {
[key: string]: any;
} | null;
/**
* The value that should be displayed on the UI for this audit.
*/
displayValue?: string | null;
/**
* An error message from a thrown error inside the audit.
*/
errorMessage?: string | null;
/**
* An explanation of the errors in the audit.
*/
explanation?: string | null;
/**
* The audit's id.
*/
id?: string | null;
/**
* A numeric value that has a meaning specific to the audit, e.g. the number of nodes in the DOM or the timestamp of a specific load event. More information can be found in the audit details, if present.
*/
numericValue?: number | null;
/**
* The score of the audit, can be null.
*/
score?: any | null;
/**
* The enumerated score display mode.
*/
scoreDisplayMode?: string | null;
/**
* The human readable title.
*/
title?: string | null;
/**
* Possible warnings that occurred in the audit, can be null.
*/
warnings?: any | null;
}
/**
* A Lighthouse category.
*/
export interface Schema$LighthouseCategoryV5 {
/**
* An array of references to all the audit members of this category.
*/
auditRefs?: Schema$AuditRefs[];
/**
* A more detailed description of the category and its importance.
*/
description?: string | null;
/**
* The string identifier of the category.
*/
id?: string | null;
/**
* A description for the manual audits in the category.
*/
manualDescription?: string | null;
/**
* The overall score of the category, the weighted average of all its audits. (The category's score, can be null.)
*/
score?: any | null;
/**
* The human-friendly name of the category.
*/
title?: string | null;
}
/**
* The Lighthouse result object.
*/
export interface Schema$LighthouseResultV5 {
/**
* Map of audits in the LHR.
*/
audits?: {
[key: string]: Schema$LighthouseAuditResultV5;
} | null;
/**
* Map of categories in the LHR.
*/
categories?: Schema$Categories;
/**
* Map of category groups in the LHR.
*/
categoryGroups?: {
[key: string]: Schema$CategoryGroupV5;
} | null;
/**
* The configuration settings for this LHR.
*/
configSettings?: Schema$ConfigSettings;
/**
* Environment settings that were used when making this LHR.
*/
environment?: Schema$Environment;
/**
* The time that this run was fetched.
*/
fetchTime?: string | null;
/**
* The final resolved url that was audited.
*/
finalUrl?: string | null;
/**
* The internationalization strings that are required to render the LHR.
*/
i18n?: Schema$I18n;
/**
* The lighthouse version that was used to generate this LHR.
*/
lighthouseVersion?: string | null;
/**
* The original requested url.
*/
requestedUrl?: string | null;
/**
* A top-level error message that, if present, indicates a serious enough problem that this Lighthouse result may need to be discarded.
*/
runtimeError?: Schema$RuntimeError;
/**
* List of all run warnings in the LHR. Will always output to at least `[]`.
*/
runWarnings?: any[] | null;
/**
* The Stack Pack advice strings.
*/
stackPacks?: Schema$StackPack[];
/**
* Timing information for this LHR.
*/
timing?: Schema$Timing;
/**
* The user agent that was used to run this LHR.
*/
userAgent?: string | null;
}
/**
* The CrUX loading experience object that contains CrUX data breakdowns.
*/
export interface Schema$PagespeedApiLoadingExperienceV5 {
/**
* The url, pattern or origin which the metrics are on.
*/
id?: string | null;
/**
* The requested URL, which may differ from the resolved "id".
*/
initial_url?: string | null;
/**
* The map of .
*/
metrics?: {
[key: string]: Schema$UserPageLoadMetricV5;
} | null;
/**
* True if the result is an origin fallback from a page, false otherwise.
*/
origin_fallback?: boolean | null;
/**
* The human readable speed "category" of the id.
*/
overall_category?: string | null;
}
/**
* The Pagespeed API response object.
*/
export interface Schema$PagespeedApiPagespeedResponseV5 {
/**
* The UTC timestamp of this analysis.
*/
analysisUTCTimestamp?: string | null;
/**
* The captcha verify result
*/
captchaResult?: string | null;
/**
* Canonicalized and final URL for the document, after following page redirects (if any).
*/
id?: string | null;
/**
* Kind of result.
*/
kind?: string | null;
/**
* Lighthouse response for the audit url as an object.
*/
lighthouseResult?: Schema$LighthouseResultV5;
/**
* Metrics of end users' page loading experience.
*/
loadingExperience?: Schema$PagespeedApiLoadingExperienceV5;
/**
* Metrics of the aggregated page loading experience of the origin
*/
originLoadingExperience?: Schema$PagespeedApiLoadingExperienceV5;
/**
* The version of PageSpeed used to generate these results.
*/
version?: Schema$PagespeedVersion;
}
/**
* The Pagespeed Version object.
*/
export interface Schema$PagespeedVersion {
/**
* The major version number of PageSpeed used to generate these results.
*/
major?: string | null;
/**
* The minor version number of PageSpeed used to generate these results.
*/
minor?: string | null;
}
/**
* Message holding the formatted strings used in the renderer.
*/
export interface Schema$RendererFormattedStrings {
/**
* The tooltip text on an expandable chevron icon.
*/
auditGroupExpandTooltip?: string | null;
/**
* The label for the initial request in a critical request chain.
*/
crcInitialNavigation?: string | null;
/**
* The label for values shown in the summary of critical request chains.
*/
crcLongestDurationLabel?: string | null;
/**
* The label shown next to an audit or metric that has had an error.
*/
errorLabel?: string | null;
/**
* The error string shown next to an erroring audit.
*/
errorMissingAuditInfo?: string | null;
/**
* The title of the lab data performance category.
*/
labDataTitle?: string | null;
/**
* The disclaimer shown under performance explaning that the network can vary.
*/
lsPerformanceCategoryDescription?: string | null;
/**
* The heading shown above a list of audits that were not computerd in the run.
*/
manualAuditsGroupTitle?: string | null;
/**
* The heading shown above a list of audits that do not apply to a page.
*/
notApplicableAuditsGroupTitle?: string | null;
/**
* The heading for the estimated page load savings opportunity of an audit.
*/
opportunityResourceColumnLabel?: string | null;
/**
* The heading for the estimated page load savings of opportunity audits.
*/
opportunitySavingsColumnLabel?: string | null;
/**
* The heading that is shown above a list of audits that are passing.
*/
passedAuditsGroupTitle?: string | null;
/**
* The label that explains the score gauges scale (0-49, 50-89, 90-100).
*/
scorescaleLabel?: string | null;
/**
* The label shown preceding important warnings that may have invalidated an entire report.
*/
toplevelWarningsMessage?: string | null;
/**
* The disclaimer shown below a performance metric value.
*/
varianceDisclaimer?: string | null;
/**
* The label shown above a bulleted list of warnings.
*/
warningHeader?: string | null;
}
/**
* Message containing a runtime error config.
*/
export interface Schema$RuntimeError {
/**
* The enumerated Lighthouse Error code.
*/
code?: string | null;
/**
* A human readable message explaining the error code.
*/
message?: string | null;
}
/**
* Message containing Stack Pack information.
*/
export interface Schema$StackPack {
/**
* The stack pack advice strings.
*/
descriptions?: {
[key: string]: string;
} | null;
/**
* The stack pack icon data uri.
*/
iconDataURL?: string | null;
/**
* The stack pack id.
*/
id?: string | null;
/**
* The stack pack title.
*/
title?: string | null;
}
/**
* Message containing the performance timing data for the Lighthouse run.
*/
export interface Schema$Timing {
/**
* The total duration of Lighthouse's run.
*/
total?: number | null;
}
/**
* A CrUX metric object for a single metric and form factor.
*/
export interface Schema$UserPageLoadMetricV5 {
/**
* The category of the specific time metric.
*/
category?: string | null;
/**
* Metric distributions. Proportions should sum up to 1.
*/
distributions?: Schema$Bucket[];
/**
* Identifies the form factor of the metric being collected.
*/
formFactor?: string | null;
/**
* The median number of the metric, in millisecond.
*/
median?: number | null;
/**
* Identifies the type of the metric.
*/
metricId?: string | null;
/**
* We use this field to store certain percentile value for this metric. For v4, this field contains pc50. For v5, this field contains pc90.
*/
percentile?: number | null;
}
export class Resource$Pagespeedapi {
context: APIRequestContext;
constructor(context: APIRequestContext);
/**
* Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information.
* @example
* ```js
* // Before running the sample:
* // - Enable the API at:
* // https://console.developers.google.com/apis/api/pagespeedonline.googleapis.com
* // - Login into gcloud by running:
* // `$ gcloud auth application-default login`
* // - Install the npm module by running:
* // `$ npm install googleapis`
*
* const {google} = require('googleapis');
* const pagespeedonline = google.pagespeedonline('v5');
*
* async function main() {
* const auth = new google.auth.GoogleAuth({
* // Scopes can be specified either as an array or as a single, space-delimited string.
* scopes: ['openid'],
* });
*
* // Acquire an auth client, and bind it to all future calls
* const authClient = await auth.getClient();
* google.options({auth: authClient});
*
* // Do the magic
* const res = await pagespeedonline.pagespeedapi.runpagespeed({
* // The captcha token passed when filling out a captcha.
* captchaToken: 'placeholder-value',
* // A Lighthouse category to run; if none are given, only Performance category will be run
* category: 'placeholder-value',
* // The locale used to localize formatted results
* locale: '[a-zA-Z]+((_|-)[a-zA-Z]+)?',
* // The analysis strategy (desktop or mobile) to use, and desktop is the default
* strategy: 'placeholder-value',
* // Required. The URL to fetch and analyze
* url: '(?i)(url:|origin:)?http(s)?://.*',
* // Campaign name for analytics.
* utm_campaign: 'placeholder-value',
* // Campaign source for analytics.
* utm_source: 'placeholder-value',
* });
* console.log(res.data);
*
* // Example response
* // {
* // "analysisUTCTimestamp": "my_analysisUTCTimestamp",
* // "captchaResult": "my_captchaResult",
* // "id": "my_id",
* // "kind": "my_kind",
* // "lighthouseResult": {},
* // "loadingExperience": {},
* // "originLoadingExperience": {},
* // "version": {}
* // }
* }
*
* main().catch(e => {
* console.error(e);
* throw e;
* });
*
* ```
*
* @param params - Parameters for request
* @param options - Optionally override request options, such as `url`, `method`, and `encoding`.
* @param callback - Optional callback that handles the response.
* @returns A promise if used with async/await, or void if used with a callback.
*/
runpagespeed(params: Params$Resource$Pagespeedapi$Runpagespeed, options: StreamMethodOptions): GaxiosPromise<Readable>;
runpagespeed(params?: Params$Resource$Pagespeedapi$Runpagespeed, options?: MethodOptions): GaxiosPromise<Schema$PagespeedApiPagespeedResponseV5>;
runpagespeed(params: Params$Resource$Pagespeedapi$Runpagespeed, options: StreamMethodOptions | BodyResponseCallback<Readable>, callback: BodyResponseCallback<Readable>): void;
runpagespeed(params: Params$Resource$Pagespeedapi$Runpagespeed, options: MethodOptions | BodyResponseCallback<Schema$PagespeedApiPagespeedResponseV5>, callback: BodyResponseCallback<Schema$PagespeedApiPagespeedResponseV5>): void;
runpagespeed(params: Params$Resource$Pagespeedapi$Runpagespeed, callback: BodyResponseCallback<Schema$PagespeedApiPagespeedResponseV5>): void;
runpagespeed(callback: BodyResponseCallback<Schema$PagespeedApiPagespeedResponseV5>): void;
}
export interface Params$Resource$Pagespeedapi$Runpagespeed extends StandardParameters {
/**
* The captcha token passed when filling out a captcha.
*/
captchaToken?: string;
/**
* A Lighthouse category to run; if none are given, only Performance category will be run
*/
category?: string[];
/**
* The locale used to localize formatted results
*/
locale?: string;
/**
* The analysis strategy (desktop or mobile) to use, and desktop is the default
*/
strategy?: string;
/**
* Required. The URL to fetch and analyze
*/
url?: string;
/**
* Campaign name for analytics.
*/
utm_campaign?: string;
/**
* Campaign source for analytics.
*/
utm_source?: string;
}
export {};
}