runpagespeed method

Future<PagespeedApiPagespeedResponseV5> runpagespeed(
  1. String url, {
  2. String? captchaToken,
  3. List<String>? category,
  4. String? locale,
  5. String? strategy,
  6. String? utmCampaign,
  7. String? utmSource,
  8. String? $fields,
})

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.

Request parameters:

url - Required. The URL to fetch and analyze Value must have pattern (?i)(url:|origin:)?http(s)?://.*.

captchaToken - The captcha token passed when filling out a captcha.

category - A Lighthouse category to run; if none are given, only Performance category will be run

locale - The locale used to localize formatted results Value must have pattern \[a-zA-Z\]+((_|-)\[a-zA-Z\]+)?.

strategy - The analysis strategy (desktop or mobile) to use, and desktop is the default Possible string values are:

  • "STRATEGY_UNSPECIFIED" : UNDEFINED.
  • "DESKTOP" : Fetch and analyze the URL for desktop browsers.
  • "MOBILE" : Fetch and analyze the URL for mobile devices.

utmCampaign - Campaign name for analytics.

utmSource - Campaign source for analytics.

$fields - Selector specifying which fields to include in a partial response.

Completes with a PagespeedApiPagespeedResponseV5.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<PagespeedApiPagespeedResponseV5> runpagespeed(
  core.String url, {
  core.String? captchaToken,
  core.List<core.String>? category,
  core.String? locale,
  core.String? strategy,
  core.String? utmCampaign,
  core.String? utmSource,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    'url': [url],
    'captchaToken': ?captchaToken == null ? null : [captchaToken],
    'category': ?category,
    'locale': ?locale == null ? null : [locale],
    'strategy': ?strategy == null ? null : [strategy],
    'utm_campaign': ?utmCampaign == null ? null : [utmCampaign],
    'utm_source': ?utmSource == null ? null : [utmSource],
    'fields': ?$fields == null ? null : [$fields],
  };

  const url_ = 'pagespeedonline/v5/runPagespeed';

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return PagespeedApiPagespeedResponseV5.fromJson(
    response_ as core.Map<core.String, core.dynamic>,
  );
}