The WebPageTest REST API gives you full access to the power and depth of WebPageTest's analysis, letting you pull performance data into your existing workflows and processes.
In this guide, we'll walk you through the process of getting up and running with you very first API test.
1. Get your API Key
Once created, your API keys are always available in your account dashboard, under API Consumers.
If you can't see any API Keys, that means you don't currently have any and you will need to create a new one.
2. Submit your first test
To make sure your API key is ready to go, let's get your first test submitted. It takes some time for a test to complete.
Copy and paste the following command into your terminal, inserting your api key and email address in place of the placeholders:
The request above will:
- Submit a test for www.webpagetest.org (using the
- Authenticate using your API key (using the
- Request a JSON response (using the
If all goes well, you should get a JSON response, similar to the one below, telling you the test has been successfully submitted (
statusCode=200), and providing you with the
testId as well as several links for digging into results once the test has been completed.
3. Navigate to the result page
All that's left is to view the test result!
If you go to the "userUrl" from the JSON result, you will see the normal "Test waiting" page that will refresh and load the test results when it completes. If you navigate to the "jsonUrl" in a browser you should see a JSON view of the test status. If you refresh the page periodically you will see the status change until it finally returns the full test result as JSON.
What comes next?
Congratulations! You've just successfully submitted your first test using the WebPageTest API. Here's a few more resources to help you take your next steps: