---
description: Before we learn more about webpagetest api, lets understand- What is WebPagetest? Webpagetest is one of the most popular and free tool for measuring webpage performance. Webpagetest enables you to run
title: WebPagetest API Tutorial with Example
image: https://www.guru99.com/images/webpagetest-api-tutorial.png
---

 

[Skip to content](#main) 

**⚡ Smart Summary**

WebPageTest API submits performance tests programmatically by using API keys and the runtest.php endpoint. Lessons cover authentication, request formats, JSON and XML response handling, and reading test result data effectively.

* ⚡ **Endpoint:** POST or GET runtest.php.
* 🔑 **Auth:** X-WPT-API-KEY header.
* 📊 **Format:** f=json or f=xml.

[ Read More ](javascript:void%280%29;) 

![WebPagetest API]()

Before we learn more about webpagetest API, let’s understand-

## What is WebPagetest?

Webpagetest is one of the most popular and free tools for measuring webpage performance. Webpagetest enables you to run web performance tests on your site from a number of different locations across the world in a number of different browsers.

[](https://www.guru99.com/images/11-2014/112714%5F1302%5FHowtouseWeb1.png)

Enter your website and click Start Test. Next, you will see the output window like below

[](https://www.guru99.com/images/11-2014/112714%5F1302%5FHowtouseWeb2.png)

From this page, you can find values for following parameters of your webpage

* Load Time – Time requires to load the page
* First Byte Time – Time when your request started to execute
* Page Size – Total Size for your Web page
* Requests – Number of Requests your Webpage made.

### WebPagetest API

Webpagetest has 2 primary API

1. To Run Tests – [http://www.webpagetest.org/runtest.php.](http://www.webpagetest.org/)
2. To Check Test Status – **http://www.webpagetest.org/**
3. To get Test Results – <http://www.webpagetest.org/>

To Run Tests:

* To run a test you can make a GET or a POST to <http://www.webpagetest.org/>.
* In response, you will either get re-directed to the results page or you will receive an XML response (depending on if XML was requested).
* You need API KEY to use Webpagetest API, and you have to contact wepagetest.org to get your API KEY. With this API key, you can submit max 100 tests per day for more you need a private instance. For Private instance – set up a test environment on your own server.
* Sample – **http://www.webpagetest.org/runtest.php?url=guru99.com&runs=1&f=xml&k=<your-api-key>**

### Set Parameters

* URL – URL to be tested
* runs – Number of test runs
* fvonly – Set to 1 to skip the Repeat View test
* f – Response Format. Set to XML to Request an XML response or JSON for JSON encoded response
* k – API Key **(required for public instance)**

### RELATED ARTICLES

* [10 Best Programming Language to Learn in 2026 ](https://www.guru99.com/best-programming-language.html "10 Best Programming Language to Learn in 2026")
* [9 Best Sublime Text Alternatives for Mac & Linux (2026) ](https://www.guru99.com/sublime-text-alternative.html "9 Best Sublime Text Alternatives for Mac & Linux (2026)")
* [Prototype Model in Software Engineering ](https://www.guru99.com/software-engineering-prototyping-model.html "Prototype Model in Software Engineering")
* [UX vs UI Design – Difference Between Them ](https://www.guru99.com/ui-vs-ux.html "UX vs UI Design – Difference Between Them")

#### To Check Test Status

* Once you submit a test, you will get the following XML response.

[](https://www.guru99.com/images/11-2014/112714%5F1302%5FHowtouseWeb3.png)

* Check testId field in response and note it
* Webpagetest is a free and popular tool so to ensure fair usage, your Request has to stand in the queue and wait for your turn.
* You can check test status by doing a GET to http://www.webpagetest.org/testStatus.php with your test id.
* Example – **http://www.webpagetest.org/testStatus.php?f=xml&test=141107\_12\_BXZ**

[](https://www.guru99.com/images/11-2014/112714%5F1302%5FHowtouseWeb4.png)

This information gives the test ID, the start time, the number of runs the test requested, etc.

#### To Check Test Results

Pass the tested to the API – **http://www.webpagetest.org/xmlResult/141107\_12\_BXZ/**

You will see the Test results in XML format like below

[](https://www.guru99.com/images/11-2014/112714%5F1302%5FHowtouseWeb5.png)

### Php Code sample to use Webpagetest API

	<?php
	$url = <a href=https://www.guru99.com //url to test
	$api_key = "<your-copy-api-key>"; // your api key
	  $webpagetest = "http://www.webpagetest.org/runtest.php?url=$url&runs=1&f=xml&k=$api_key"; 
	$xmlres = simplexml_load_file($webpagetest);
	$testid = $xmlres->data->testId;        
	echo "Test id : ".$testid." For url : ".$url;
	?>

* Now Make another call after some time to get test results

 <?php
	$test_id = "<test-id-you-got-from-request-call>";
	$weburl = "http://www.webpagetest.org/xmlResult/$test_id/";
	 $xmlres = simplexml_load_file($weburl);
	 if($xmlres){
	$loadtime = ($xmlres->data->average->firstView->loadTime)/1000;
	echo "WebPage loadtime is : ".$loadtime;
	}
	?>

## FAQs

⚡ How do I get a WebPageTest API key?

Sign up at webpagetest.org and request a key from the dashboard. Paid plans start at $15 monthly.

🤖 How does AI improve WebPageTest analysis?

AI tools parse JSON, summarise Core Web Vitals, flag regressions, and recommend image, CSS, or JS fixes.

💡 Can AI write WebPageTest API scripts?

Yes. Copilot generates Node and Python scripts that submit tests, poll status, and parse results.

#### Summarize this post with:

ChatGPT Perplexity Grok Google AI 

**Stay Updated on AI** **Get Weekly AI Skills, Trends, Actionable Advice.** 

##### Sign up for the newsletter

Subscribe for Free 

You have successfully subscribed.  
Please check your inbox. 

![AI-Newsletter]() Chosen by over **350,000+** professionals 

[Scroll to top ](#wrapper)Scroll to top 

× 

Toggle Menu Close 

Search for: 

Search

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.guru99.com/#organization","name":"Guru99","sameAs":["https://www.facebook.com/Guru99Official","https://twitter.com/guru99com"],"logo":{"@type":"ImageObject","@id":"https://www.guru99.com/#logo","url":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","contentUrl":"https://www.guru99.com/images/guru99-logo-v1-150x59.png","caption":"Guru99","inLanguage":"en-US"}},{"@type":"WebSite","@id":"https://www.guru99.com/#website","url":"https://www.guru99.com","name":"Guru99","publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https://www.guru99.com/images/webpagetest-api-tutorial.png","url":"https://www.guru99.com/images/webpagetest-api-tutorial.png","width":"700","height":"250","caption":"WebPagetest API Tutorial","inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"https://www.guru99.com/how-to-use-webpagetest-api.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":"1","item":{"@id":"https://www.guru99.com","name":"Home"}},{"@type":"ListItem","position":"2","item":{"@id":"https://www.guru99.com/sdlc","name":"Software Engineering"}},{"@type":"ListItem","position":"3","item":{"@id":"https://www.guru99.com/how-to-use-webpagetest-api.html","name":"WebPagetest API Tutorial with Example"}}]},{"@type":"WebPage","@id":"https://www.guru99.com/how-to-use-webpagetest-api.html#webpage","url":"https://www.guru99.com/how-to-use-webpagetest-api.html","name":"WebPagetest API Tutorial with Example","dateModified":"2026-06-25T12:34:34+05:30","isPartOf":{"@id":"https://www.guru99.com/#website"},"primaryImageOfPage":{"@id":"https://www.guru99.com/images/webpagetest-api-tutorial.png"},"inLanguage":"en-US","breadcrumb":{"@id":"https://www.guru99.com/how-to-use-webpagetest-api.html#breadcrumb"}},{"@type":"Person","@id":"https://www.guru99.com/author/lucas","name":"Lucas Bennett","description":"I'm Lucas Bennett, a software engineering expert, providing top-notch tutorials to enhance your coding skills and master the latest technologies.","url":"https://www.guru99.com/author/lucas","image":{"@type":"ImageObject","@id":"https://www.guru99.com/images/lucas-bennett-author.png","url":"https://www.guru99.com/images/lucas-bennett-author.png","caption":"Lucas Bennett","inLanguage":"en-US"},"worksFor":{"@id":"https://www.guru99.com/#organization"}},{"articleSection":"Software Engineering","headline":"WebPagetest API Tutorial with Example","description":"Before we learn more about webpagetest api, lets understand- What is WebPagetest? Webpagetest is one of the most popular and free tool for measuring webpage performance. Webpagetest enables you to run","keywords":"bigdata, programming, database, server","speakable":{"@type":"SpeakableSpecification","cssSelector":[".entry-title",".summary"]},"@type":"Article","author":{"@id":"https://www.guru99.com/author/lucas","name":"Lucas Bennett"},"dateModified":"2026-06-25T12:34:34+05:30","image":{"@id":"https://www.guru99.com/images/webpagetest-api-tutorial.png"},"copyrightYear":"2026","name":"WebPagetest API Tutorial with Example","subjectOf":[{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"How do I get a WebPageTest API key?","acceptedAnswer":{"@type":"Answer","text":"Sign up at webpagetest.org and request a key from the dashboard. Paid plans start at $15 monthly."}},{"@type":"Question","name":"How does AI improve WebPageTest analysis?","acceptedAnswer":{"@type":"Answer","text":"AI tools parse JSON, summarise Core Web Vitals, flag regressions, and recommend image, CSS, or JS fixes."}},{"@type":"Question","name":"Can AI write WebPageTest API scripts?","acceptedAnswer":{"@type":"Answer","text":"Yes. Copilot generates Node and Python scripts that submit tests, poll status, and parse results."}}]}],"@id":"https://www.guru99.com/how-to-use-webpagetest-api.html#schema-1119189","isPartOf":{"@id":"https://www.guru99.com/how-to-use-webpagetest-api.html#webpage"},"publisher":{"@id":"https://www.guru99.com/#organization"},"inLanguage":"en-US","mainEntityOfPage":{"@id":"https://www.guru99.com/how-to-use-webpagetest-api.html#webpage"}}]}
```
