Running webpagetest from CLI

Sometimes you have a need to run web page load speed test without an UI. And of course, as per usual, there’s a node module for that.

I’ve been checking out https://www.webpagetest.org/ and they do provide a web interface, and an api, as well https://sites.google.com/a/webpagetest.org/docs/advanced-features/webpagetest-restful-apis.

Besides those two sources, there’s also a node module for running the tests:

https://github.com/marcelduran/webpagetest-api

Here’s how to get it working (running on macOS at the moment).

  1. git clone git@github.com:marcelduran/webpagetest-api.git
  2. cd webpagetest-api
  3. docker build -t webpagetest-api .
  4. Get the API Key from webpagetest.org/getkey.php
  5. Run the test: docker run -it –rm webpagetest-api -k YOURAPIKEY test https://twitter.com/marcelduran
{
  "statusCode": 200,
  "statusText": "Ok",
  "data": {
    "testId": "190206_19_f4ed62b215aa61ed44085cdf0cac1779",
    "ownerKey": "c65d1fd5da5233aada1c4b1064bf39d05b4a81c4",
    "jsonUrl": "https://www.webpagetest.org/jsonResult.php?test=190206_19_f4ed62b215aa61ed44085cdf0cac1779",
    "xmlUrl": "https://www.webpagetest.org/xmlResult/190206_19_f4ed62b215aa61ed44085cdf0cac1779/",
    "userUrl": "https://www.webpagetest.org/result/190206_19_f4ed62b215aa61ed44085cdf0cac1779/",
    "summaryCSV": "https://www.webpagetest.org/result/190206_19_f4ed62b215aa61ed44085cdf0cac1779/page_data.csv",
    "detailCSV": "https://www.webpagetest.org/result/190206_19_f4ed62b215aa61ed44085cdf0cac1779/requests.csv"
  }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s