O'Reilly logo

Using WebPageTest by Marcel Duran, Andy Davies, Rick Viscomi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. WebPageTest API

The WebPageTest API is RESTful, meaning that commands with parameters are submitted by either sending a POST or GET request to WebPageTest server PHP endpoints. The API is not fully normalized; output formats vary from endpoint to endpoint. The vast majority output JSON/JSONP and XML, but some output CSV, TSV, HTML, and plain text. The WebPageTest UI uses its API, so every command and option found on the user interface has a correspondent in the API.

In this chapter you will learn how to programatically run tests and fetch results from WebPageTest in both public and private instances. This will allow integration with an existing web development pipeline, as well as the automation of the whole process of running a test and reading its results once the test is complete.

Getting Started

Before getting ready to start using the WebPageTest API, you will need direct access to either the public instance of the WebPageTest server at www.webpagetest.org or a private instance of WebPageTest, covered in Chapter 11.

Requesting a Key

An API key is required for using the public instance at www.webpagetest.org. It’s generally not necessary for private instances of WebPageTest unless required by its administrator. The API key is only used by the run-test endpoint /runtest.php.

Public instance

For the public instance, a trial key can be obtained by filling out a form at http://www.webpagetest.org/getkey.php.

Tip

Agreeing with the terms of service is required as the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required