NAVNavbar
Logo
cURL php NodeJS Python cSharp

Audits in OnPage Lighthouse API

 
The OnPage Lighthouse API is based on Google’s open-source Lighthouse project and provides data on the quality of web pages.

Lighthouse Audits are objects containing the results of the page quality tests run by Lighthouse. This endpoint will provide you with a list of titles available for Lighthouse Audits. You can obtain the results of certain audits by specifying the corresponding titles in your Task POST requests.

OnPage Lighthouse API is based on an open-source Lighthouse project. You can find the official documentation here.

Instead of ‘login’ and ‘password’ use your credentials from https://app.dataforseo.com/api-access

<?php
// You can download this file from here https://cdn.dataforseo.com/v3/examples/php/php_RestClient.zip
require('RestClient.php');
$api_url = 'https://api.dataforseo.com/';
try {
	// Instead of 'login' and 'password' use your credentials from https://app.dataforseo.com/api-access
	$client = new RestClient($api_url, null, 'login', 'password');
} catch (RestClientException $e) {
	echo "\n";
	print "HTTP code: {$e->getHttpCode()}\n";
	print "Error code: {$e->getCode()}\n";
	print "Message: {$e->getMessage()}\n";
	print  $e->getTraceAsString();
	echo "\n";
	exit();
}
try {
	// using this method you can get a list of available audits
	// GET /v3/on_page/lighthouse/audits
	$result = $client->get('/v3/on_page/lighthouse/audits');
	print_r($result);
	// do something with result
} catch (RestClientException $e) {
	echo "\n";
	print "HTTP code: {$e->getHttpCode()}\n";
	print "Error code: {$e->getCode()}\n";
	print "Message: {$e->getMessage()}\n";
	print  $e->getTraceAsString();
	echo "\n";
}
$client = null;
?>


The list of available audits:

{
    "version": "0.1.20210713",
    "status_code": 20000,
    "status_message": "Ok.",
    "time": "0.3788 sec.",
    "cost": 0,
    "tasks_count": 1,
    "tasks_error": 0,
    "tasks": [
        {
            "id": "07191605-1535-0325-0000-788f1ca82eb1",
            "status_code": 20000,
            "status_message": "Ok.",
            "time": "0.2968 sec.",
            "cost": 0,
            "result_count": 1,
            "path": [
                "v3",
                "on_page",
                "lighthouse",
                "audits"
            ],
            "data": {
                "api": "on_page",
                "function": "lighthouse"
            },
            "result": [
                {
                    "audits": [
                        "accessibility\/accesskeys",
                        "accessibility\/aria-allowed-attr",
                        "accessibility\/aria-command-name",
                        "accessibility\/aria-hidden-body",
                        "accessibility\/aria-hidden-focus",
                        "accessibility\/aria-input-field-name",
                        "accessibility\/aria-meter-name",
                        "accessibility\/aria-progressbar-name",
                        "accessibility\/aria-required-attr",
                        "accessibility\/aria-required-children",
                        "accessibility\/aria-required-parent",
                        "accessibility\/aria-roles",
                        "accessibility\/aria-toggle-field-name",
                        "accessibility\/aria-tooltip-name",
                        "accessibility\/aria-treeitem-name",
                        "accessibility\/aria-valid-attr-value",
                        "accessibility\/aria-valid-attr",
                        "accessibility\/button-name",
                        "accessibility\/bypass",
                        "accessibility\/color-contrast",
                        "accessibility\/definition-list",
                        "accessibility\/dlitem",
                        "accessibility\/document-title",
                        "accessibility\/duplicate-id-active",
                        "accessibility\/duplicate-id-aria",
                        "accessibility\/form-field-multiple-labels",
                        "accessibility\/frame-title",
                        "accessibility\/heading-order",
                        "accessibility\/html-has-lang",
                        "accessibility\/html-lang-valid",
                        "accessibility\/image-alt",
                        "accessibility\/input-image-alt",
                        "accessibility\/label",
                        "accessibility\/link-name",
                        "accessibility\/list",
                        "accessibility\/listitem",
                        "accessibility\/manual\/custom-controls-labels",
                        "accessibility\/manual\/custom-controls-roles",
                        "accessibility\/manual\/focus-traps",
                        "accessibility\/manual\/focusable-controls",
                        "accessibility\/manual\/interactive-element-affordance",
                        "accessibility\/manual\/logical-tab-order",
                        "accessibility\/manual\/managed-focus",
                        "accessibility\/manual\/offscreen-content-hidden",
                        "accessibility\/manual\/use-landmarks",
                        "accessibility\/manual\/visual-order-follows-dom",
                        "accessibility\/meta-refresh",
                        "accessibility\/meta-viewport",
                        "accessibility\/object-alt",
                        "accessibility\/tabindex",
                        "accessibility\/td-headers-attr",
                        "accessibility\/th-has-data-cells",
                        "accessibility\/valid-lang",
                        "accessibility\/video-caption",
                        "apple-touch-icon",
                        "autocomplete",
                        "bootup-time",
                        "byte-efficiency\/duplicated-javascript",
                        "byte-efficiency\/efficient-animated-content",
                        "byte-efficiency\/legacy-javascript",
                        "byte-efficiency\/modern-image-formats",
                        "byte-efficiency\/offscreen-images",
                        "byte-efficiency\/render-blocking-resources",
                        "byte-efficiency\/total-byte-weight",
                        "byte-efficiency\/unminified-css",
                        "byte-efficiency\/unminified-javascript",
                        "byte-efficiency\/unused-css-rules",
                        "byte-efficiency\/unused-javascript",
                        "byte-efficiency\/uses-long-cache-ttl",
                        "byte-efficiency\/uses-optimized-images",
                        "byte-efficiency\/uses-responsive-images-snapshot",
                        "byte-efficiency\/uses-responsive-images",
                        "byte-efficiency\/uses-text-compression",
                        "content-width",
                        "critical-request-chains",
                        "csp-xss",
                        "deprecations",
                        "diagnostics",
                        "dobetterweb\/appcache-manifest",
                        "dobetterweb\/charset",
                        "dobetterweb\/doctype",
                        "dobetterweb\/dom-size",
                        "dobetterweb\/external-anchors-use-rel-noopener",
                        "dobetterweb\/geolocation-on-start",
                        "dobetterweb\/inspector-issues",
                        "dobetterweb\/js-libraries",
                        "dobetterweb\/no-document-write",
                        "dobetterweb\/no-vulnerable-libraries",
                        "dobetterweb\/notification-on-start",
                        "dobetterweb\/password-inputs-can-be-pasted-into",
                        "dobetterweb\/uses-http2",
                        "dobetterweb\/uses-passive-event-listeners",
                        "errors-in-console",
                        "final-screenshot",
                        "font-display",
                        "full-page-screenshot",
                        "image-aspect-ratio",
                        "image-size-responsive",
                        "installable-manifest",
                        "is-on-https",
                        "large-javascript-libraries",
                        "largest-contentful-paint-element",
                        "layout-shift-elements",
                        "long-tasks",
                        "main-thread-tasks",
                        "mainthread-work-breakdown",
                        "manual\/pwa-cross-browser",
                        "manual\/pwa-each-page-has-url",
                        "manual\/pwa-page-transitions",
                        "maskable-icon",
                        "metrics",
                        "metrics\/cumulative-layout-shift",
                        "metrics\/first-contentful-paint-3g",
                        "metrics\/first-contentful-paint",
                        "metrics\/first-meaningful-paint",
                        "metrics\/interactive",
                        "metrics\/largest-contentful-paint",
                        "metrics\/max-potential-fid",
                        "metrics\/speed-index",
                        "metrics\/total-blocking-time",
                        "network-requests",
                        "network-rtt",
                        "network-server-latency",
                        "no-unload-listeners",
                        "non-composited-animations",
                        "performance-budget",
                        "predictive-perf",
                        "preload-fonts",
                        "preload-lcp-image",
                        "redirects-http",
                        "redirects",
                        "resource-summary",
                        "screenshot-thumbnails",
                        "script-treemap-data",
                        "seo\/canonical",
                        "seo\/crawlable-anchors",
                        "seo\/font-size",
                        "seo\/hreflang",
                        "seo\/http-status-code",
                        "seo\/is-crawlable",
                        "seo\/link-text",
                        "seo\/manual\/structured-data",
                        "seo\/meta-description",
                        "seo\/plugins",
                        "seo\/robots-txt",
                        "seo\/tap-targets",
                        "server-response-time",
                        "service-worker",
                        "splash-screen",
                        "themed-omnibox",
                        "third-party-facades",
                        "third-party-summary",
                        "timing-budget",
                        "unsized-images",
                        "user-timings",
                        "uses-rel-preconnect",
                        "uses-rel-preload",
                        "valid-source-maps",
                        "viewport"
                    ]
                }
            ]
        }
    ]
}

Description of the fields in the results array:

Field name Type Description
version string the current version of the API
status_code integer general status code
you can find the full list of the response codes here
Note: we strongly recommend designing a necessary system for handling related exceptional or error conditions
status_message string general informational message
you can find the full list of general informational messages here
time string execution time, seconds
cost float total tasks cost, USD
tasks_count integer the number of tasks in the tasks array
tasks_error integer the number of tasks in the tasks array returned with an error
tasks array array of tasks
        id string task identifier
unique task identifier in our system in the UUID format
        status_code integer status code of the task
generated by DataForSEO; can be within the following range: 10000-60000
you can find the full list of the response codes here
        status_message string informational message of the task
you can find the full list of general informational messages here
        time string execution time, seconds
        cost float cost of the task, USD
        result_count integer number of elements in the result array
        path array URL path
        data object contains the same parameters that you specified in the POST request
        result array array of results
            audits array the list of available lighthouse audits
an array containing the titles of available audits
Note: the titles can change depending on if the audit passed or failed and may contain markdown code

‌‌