Class: Google::Apis::PagespeedonlineV5::PagespeedInsightsService

Inherits:
Core::BaseService
  • Object
show all
Defined in:
generated/google/apis/pagespeedonline_v5/service.rb

Overview

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.

Examples:

require 'google/apis/pagespeedonline_v5'

Pagespeedonline = Google::Apis::PagespeedonlineV5 # Alias the module
service = Pagespeedonline::PagespeedInsightsService.new

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePagespeedInsightsService

Returns a new instance of PagespeedInsightsService.



48
49
50
51
# File 'generated/google/apis/pagespeedonline_v5/service.rb', line 48

def initialize
  super('https://pagespeedonline.googleapis.com/', '')
  @batch_path = 'batch'
end

Instance Attribute Details

#keyString

Returns 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.

Returns:

  • (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.



41
42
43
# File 'generated/google/apis/pagespeedonline_v5/service.rb', line 41

def key
  @key
end

#quota_userString

Returns 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.

Returns:

  • (String)

    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.



46
47
48
# File 'generated/google/apis/pagespeedonline_v5/service.rb', line 46

def quota_user
  @quota_user
end

Instance Method Details

#runpagespeed_pagespeedapi(url, captcha_token: nil, category: nil, locale: nil, strategy: nil, utm_campaign: nil, utm_source: nil, fields: nil, quota_user: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::PagespeedonlineV5::PagespeedApiPagespeedResponseV5

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.

Parameters:

  • url (String)

    Required. The URL to fetch and analyze

  • captcha_token (String) (defaults to: nil)

    The captcha token passed when filling out a captcha.

  • category (Array<String>, String) (defaults to: nil)

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

  • locale (String) (defaults to: nil)

    The locale used to localize formatted results

  • strategy (String) (defaults to: nil)

    The analysis strategy (desktop or mobile) to use, and desktop is the default

  • utm_campaign (String) (defaults to: nil)

    Campaign name for analytics.

  • utm_source (String) (defaults to: nil)

    Campaign source for analytics.

  • fields (String) (defaults to: nil)

    Selector specifying which fields to include in a partial response.

  • quota_user (String) (defaults to: nil)

    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.

  • options (Google::Apis::RequestOptions) (defaults to: nil)

    Request-specific options

Yields:

  • (result, err)

    Result & error if block supplied

Yield Parameters:

Returns:

Raises:

  • (Google::Apis::ServerError)

    An error occurred on the server and the request can be retried

  • (Google::Apis::ClientError)

    The request is invalid and should not be retried without modification

  • (Google::Apis::AuthorizationError)

    Authorization is required



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'generated/google/apis/pagespeedonline_v5/service.rb', line 88

def runpagespeed_pagespeedapi(url, captcha_token: nil, category: nil, locale: nil, strategy: nil, utm_campaign: nil, utm_source: nil, fields: nil, quota_user: nil, options: nil, &block)
  command = make_simple_command(:get, 'pagespeedonline/v5/runPagespeed', options)
  command.response_representation = Google::Apis::PagespeedonlineV5::PagespeedApiPagespeedResponseV5::Representation
  command.response_class = Google::Apis::PagespeedonlineV5::PagespeedApiPagespeedResponseV5
  command.query['captchaToken'] = captcha_token unless captcha_token.nil?
  command.query['category'] = category unless category.nil?
  command.query['locale'] = locale unless locale.nil?
  command.query['strategy'] = strategy unless strategy.nil?
  command.query['url'] = url unless url.nil?
  command.query['utm_campaign'] = utm_campaign unless utm_campaign.nil?
  command.query['utm_source'] = utm_source unless utm_source.nil?
  command.query['fields'] = fields unless fields.nil?
  command.query['quotaUser'] = quota_user unless quota_user.nil?
  execute_or_queue_command(command, &block)
end