Skip to content

Commit 0190970

Browse files
author
Mike Kozicki
authored
Merge pull request #97 from catchpoint/api_key_header_only
Update docs for passing api key in header only change
2 parents bb09ffd + f6e150c commit 0190970

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

src/api/reference.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ The WebPageTest API uses API keys to authenticate all tests submitted to the pub
2121
API keys may or may not be required for requests made to any [private instances](/private-instances/) you maintain on your own. Check with the administrator of your private instance to verify.
2222
:::
2323

24-
You can pass your API key along with tests requests by using the `k` parameter.
24+
You can pass your API key along with tests requests by using the `X-WPT-API-KEY` HTTP header.
2525

2626
```text
27-
https://www.webpagetest.org/runtest.php?url={your_domain}&k={your_api_key}
27+
curl --request POST --url https://www.webpagetest.org/runtest.php?url={your_domain} --header "X-WPT-API-KEY: {your_api_key}"
2828
```
29-
30-
If you prefer, instead of passing the `k` parameter, you may pass the request header `X-WPT-API-KEY`
31-
3229
::: warning
3330
Your API keys are directly tied to your account, so be sure to keep them secure. Avoid sharing them in any public area, such as GitHub or client-side code.
3431
:::
@@ -55,13 +52,13 @@ You can optionally set the response format using the `f` parameter to return eit
5552

5653
```text
5754
//this will result in a redirect
58-
https://www.webpagetest.org/runtest.php?url={your_domain}&k={your_api_key}
55+
curl --request POST https://www.webpagetest.org/runtest.php?url={your_domain} --header "X-WPT-API-KEY: {your_api_key}"
5956
6057
//this will return an XML response
61-
https://www.webpagetest.org/runtest.php?url={your_domain}&k={your_api_key}&f=xml
58+
curl --request POST https://www.webpagetest.org/runtest.php?url={your_domain}&f=xml --header "X-WPT-API-KEY: {your_api_key}"
6259
6360
//this will return a JSON response
64-
https://www.webpagetest.org/runtest.php?url={your_domain}&k={your_api_key}&f=json
61+
curl --request POST https://www.webpagetest.org/runtest.php?url={your_domain}&f=json --header "X-WPT-API-KEY: {your_api_key}"
6562
```
6663

6764
Here's an example response when the format parameter is provided to the endpoint:
@@ -125,10 +122,10 @@ A URL to the full detailed results (including request-level data and timings) in
125122

126123
### Full List of Parameters
127124
::: api-list
125+
- `X-WPT-API-KEY` <small>header, required</small>
126+
API Key. Applies only to calls made to the runtest.php endpoint. *API Key is optional for any private instances you maintain on your own.
128127
- `url` <small>required</small>
129128
The URL to be tested. The value must be UTF-8 encoded to work.
130-
- `k` <small>required</small>
131-
API Key. Applies only to calls made to the runtest.php endpoint. *API Key is optional for any private instances you maintain on your own.
132129
- `label` <small>optional</small>
133130
A label for the test.
134131
- `location` <small>optional</small>
@@ -317,7 +314,7 @@ Browser is only required in a Chrome/Firefox install where wptdriver is configur
317314

318315
### Available locations for API calls
319316

320-
On the public instance with an API key that starts with "A.", only locations listed [here](https://www.webpagetest.org/getLocations.php?k=A&f=html) are available for API calls. Others will return `invalid location` when requested.
317+
On the public instance with an API key that starts with "A.", only locations listed [here](curl --request GET --url https://www.webpagetest.org/getLocations.php?&f=html --header "X-WPT-API-KEY: {your_api_key}") are available for API calls. Others will return `invalid location` when requested.
321318

322319
### Examples
323320
Test www.aol.com and redirect to the results page:
@@ -603,14 +600,14 @@ Request ID. Will echo back in the response object.
603600
To cancel a test that has not started running, you can use the http://www.webpagetest.org/cancelTest.php endpoint.
604601

605602
```text
606-
http://www.webpagetest.org/cancelTest.php?test=210328_XiMJ_3c426d8c00c689f22f4097cbb1dfd697&k=81c119174fe742f7a2d778d0a505d096\
603+
curl http://www.webpagetest.org/cancelTest.php?test=210328_XiMJ_3c426d8c00c689f22f4097cbb1dfd697 --header "X-WPT-API-KEY: {your_api_key}"
607604
```
608605

609606
### Full List of Parameters
610607
::: api-list
611-
- `k` <small>required</small>
608+
- `X-WPT-API-KEY` <small>header, required</small>
612609
API Key. *API Key is optional for any private instances you maintain on your own.
613-
- `test` <small>required</small>
610+
- `test` <small>required</small>
614611
The test ID for the test you want to cancel.
615612
:::
616613
## Retrieving Available Locations
@@ -787,10 +784,10 @@ By default, a sucessful request to the /testBalance.php endpoint will result in
787784

788785
```text
789786
//this will result in a JSON response
790-
https://webpagetest.org/testBalance.php?k={your_api_key}
787+
curl https://webpagetest.org/testBalance.php --header "X-WPT-API-KEY: {your_api_key}"
791788
792789
//this will result in an XML response
793-
https://webpagetest.org/testBalance.php?k={your_api_key}&f=xml
790+
curl https://webpagetest.org/testBalance.php?f=xml --header "X-WPT-API-KEY: {your_api_key}"
794791
```
795792

796793
Here's an example response:
@@ -832,6 +829,6 @@ If your API key is invalid, or expired, you will instead see an `error` property
832829
```
833830
### Full List of Parameters
834831
::: api-list
835-
- `k` <small>required</small>
832+
- `X-WPT-API-KEY` <small>header, required</small>
836833
API Key. *API Key is optional for any private instances you maintain on your own.
837834
:::

0 commit comments

Comments
 (0)