Skip to main content

SpeedLab API (Beta)

Your guide to running Web Page Peformance tests with SpeedLab on BrowserStack.

Introduction

SpeedLab gives you instant access to over 16 Real Devices & Desktop browsers. Running your web page performance tests with SpeedLab on BrowserStack is simple. This guide will help you in:

  1. SpeedLab Test Configuration
  2. Running a Test on SpeedLab
  3. Fetch SpeedLab Test Results

Prerequisites

  • You will need a BrowserStack account. You’ll be able to run tests on SpeedLab with a Free account.
  • You need to have any of the Automate, App Automate or App Live Username and Access key, which you can find in your account settings.

SpeedLab Test Configuration

Protip: You can use Speedlab Meta APIs to fetch a list of Browsers & Devices, Network Throttling options as well as Locations from where you could run the test.

Desktop Browsers

Usage

GET https://api.browserstack.com/speedlab/beta/meta/desktops

Sample Code

curl -u "USERNAME:ACCESS_KEY" \
  -X GET https://api.browserstack.com/speedlab/beta/meta/desktops \
  -H 'Accept: application/json'

Response

{
  "success": true,
  "desktops": [
    {
      "os": "os x",
      "os_version": "catalina",
      "browser_name": "firefox",
      "browser_version": "93"
    }
  ]
}

Mobile Device Browsers

Usage

GET https://api.browserstack.com/speedlab/beta/meta/devices

Sample Code

curl -u "USERNAME:ACCESS_KEY" \
  -X GET https://api.browserstack.com/speedlab/beta/meta/devices \
  -H 'Accept: application/json'

Response

{
  "success": true,
  "devices": [
    {
      "os": "android",
      "os_version": "9.0",
      "device": "samsung galaxy s10"
    }
  ]
}

Regions

You could set a region from where you wish to run the SpeedLab test.

Usage

GET https://api.browserstack.com/speedlab/beta/meta/regions

Sample Code

# You can also use wget
curl -u "USERNAME:ACCESS_KEY" \
  -X GET https://api.browserstack.com/speedlab/beta/meta/regions \
  -H 'Accept: application/json'

Response

{
  "success": true,
  "regions": ["euw", "usw", "use", "apse"]
}

Network Throttling

Usage

GET https://api.browserstack.com/speedlab/beta/meta/networks

Sample Code

curl 
  -u "USERNAME:ACCESS_KEY" \
  -X GET https://api.browserstack.com/speedlab/beta/meta/networks \
  -H 'Accept: application/json'

Response

{
  "success": true,
  "networks": {
    "mobile": [
      {
        "label": "4G",
        "network": "9 Mbps, 170ms RTT",
        "value": "4g_normal"
      }
    ],
    "desktop": [
      {
        "label": "Broadband Fast",
        "network": "40/40 Mbps, 20ms RTT",
        "value": "broadband_fast"
      }
    ]
  }
}

Running a Test on SpeedLab

To run web performance test with SpeedLab on BrowserSatck, follow the below steps:

Note: You can find several code examples which will help you get started with the SpeedLab API on our SpeedLab API GitHub sample scripts repo.

Configure your Test

You could configure your test by selecting specific Desktop & Device Browsers you wish to test and you can choose the Location and set Network Throttling for the browsers. For more information, refer to the Meta APIs.

Generate a Report

Once you’ve configured your test, use the below code snippet to initiate your first Web Page Performance Test report.

Sample Code

curl -X POST https://api.browserstack.com/speedlab/beta/meta/report \
  -u "USERNAME:ACCESS_KEY" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  --data '{"url": "http://example.com", "devices": [{"os": "android", "os_version": "9.0", "device": "samsung galaxy s10" }], "desktops": [{ "os": "os x", "os_version": "mojave", "browser_name": "chrome", "browser_version": "75.0" }], "region": "use", "desktop_network": "broadband_normal", "device_network": "4g_normal" }'

Response

{
  "success": true,
  "report_id": "REPORT_ID",
  "test_configuration": {
    "url": "http://example.com",
    "region": "use",
    "device_network": {
      "label": "4G",
      "network": "9 Mbps, 170ms RTT",
      "value": "4g_normal"
    },
    "desktop_network": {
      "label": "Broadband",
      "network": "5/1 Mbps, 28ms RTT",
      "value": "broadband_normal"
    },
    "devices": [
      {
        "os": "android",
        "os_version": 9,
        "device": "samsung galaxy s10"
      }
    ],
    "desktops": [
      {
        "os": "os x",
        "os_version": "mojave",
        "browser_name": "chrome",
        "browser_version": 75
      }
    ]
  }
}

Fetch SpeedLab Test Results

Once the report is generated, you can fetch the results by passing the Report Id.

Sample Code

curl -X GET https://api.browserstack.com/speedlab/beta/{id} \
  -H 'Accept: application/json'

Response

{
  "success": true,
  "test_configuration": {
    "url": "http://example.com",
    "region": "use",
    "device_network": {
      "label": "4G",
      "network": "9 Mbps, 170ms RTT",
      "value": "4g_normal"
    },
    "desktop_network": {
      "label": "Broadband",
      "network": "5/1 Mbps, 28ms RTT",
      "value": "broadband_normal"
    },
    "devices": [
      {
        "os": "android",
        "os_version": 9,
        "device": "samsung galaxy s10"
      }
    ],
    "desktops": [
      {
        "os": "os x",
        "os_version": "mojave",
        "browser_name": "chrome",
        "browser_version": 75
      },
    ],
    "report_id": "REPORT_ID"
  },
  "status": "complete",
  "report_status": true,
  "results": [
    {
      "browser_name": "chrome",
      "os": "OS X",
      "os_version": "Mojave",
      "browser_version": "75.0",
      "report": [
        {
          "resource_summary": {
            "html": {
              "content_size": 1256,
              "requests": 1
            },
            "css": {
              "content_size": 0,
              "requests": 0
            },
            "javascript": {
              "content_size": 0,
              "requests": 0
            },
            "image": {
              "content_size": 0,
              "requests": 0
            },
            "font": {
              "content_size": 0,
              "requests": 0
            }
          },
          "cpu": {
            "long_tasks": {
              "tasks": 1,
              "total_duration": 134.9599999957718
            },
            "categories": {
              "parse_html": 7,
              "style_layout": 158,
              "paint_composite_render": 4,
              "script_parse_compile": 0,
              "script_evaluation": 7,
              "garbage_collection": 0,
              "other": 41
            }
          },
          "navigation_timings": {
            "dns_lookup": 0,
            "tcp_connect": 31,
            "ttfb": 116,
            "response": 36,
            "dom_processing": 173,
            "on_load": 0,
            "browser_processing": 3,
            "page_load_time": 173
          },
          "visual_metrics": {
            "speed_index": 400,
            "visually_complete": 400,
            "visually_complete_85": 400,
            "visually_complete_95": 400,
            "visually_complete_99": 400,
            "last_visual_change": 400
          },
          "web_vitals": {
            "fcp": 342,
            "lcp": 0,
            "cls": 0,
            "tbt": 0
          },
          "har_logs": "HAR_LOGS_URL",
          "filmstrips": {
            "fcp": "FILM_STRIPS_FCP_URL",
            "visually_complete_85": "VC_85_URL",
            "visually_complete_95": "VC_95_URL",
            "visually_complete_99": "VC_99_URL",
            "page_load_time": "PAGE_LOAD_TIME_URL",
            "dom_content_load_time": "DOM_CONTENT_LOAD_URL",
            "last_visual_change": "LAST_VISUAL_CHANGE_URL"
          }
        }
      ]
    },
    {
      "browser_name": "chrome",
      "os": "android",
      "os_version": "9.0",
      "device": "Samsung Galaxy S10",
      "report": [
        {
          "navigation_timings": {
            "dns_lookup": 0,
            "tcp_connect": 0,
            "ttfb": 0,
            "response": 0,
            "dom_processing": 0,
            "on_load": 0,
            "browser_processing": 0,
            "page_load_time": 0
          },
          "visual_metrics": {
            "speed_index": 0,
            "visually_complete": 0,
            "visually_complete_85": 0,
            "visually_complete_95": 0,
            "visually_complete_99": 0,
            "last_visual_change": 0
          },
          "web_vitals": {
            "fcp": 0,
            "lcp": 0,
            "cls": 0,
            "tbt": 0
          }
        }
      ]
    },
    {
      "audit_logs": "AUDIT_LOGS_URL"
    }
  ]
}

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Talk to an Expert