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

Get Using WebPageTest now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.