SpeedLab API (Beta)
Your guide to running Web Page Peformance tests with SpeedLab on BrowserStack.
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:
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
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 BrowserStack, follow the below steps:
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/report \
-u "USERNAME:ACCESS_KEY" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
--data '{"url":"http://example.com","device":{"os":"ios","os_version":14,"device":"iphone xs"},"region":"euw","device_network":"lte"}'
Response
{
"success": true,
"report_id": "REPORT_ID",
"test_configuration": {
"url": "http://example.com",
"region": "euw",
"device_network": {
"label": "LTE",
"network": "12 Mbps, 70ms RTT",
"value": "lte"
},
"device": {
"os": "ios",
"os_version": 14,
"device": "iphone xs"
}
}
}
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/report/{id} \
-H 'Accept: application/json'
Response
{
"success": true,
"test_configuration": {
"url": "http://example.com",
"region": "euw",
"device_network": {
"label": "LTE",
"network": "12 Mbps, 70ms RTT",
"value": "lte"
},
"device": {
"os": "ios",
"os_version": 14,
"device": "iphone xs"
},
"report_id": "REPORT_ID"
},
"status": "complete",
"report_status": false,
"results": [
{
"median_run": {
"navigation_timings": {
"dns_lookup": 0,
"tcp_connect": 44,
"ttfb": 101,
"response": 130,
"dom_processing": 775,
"on_load": 0,
"page_load_time": 1480,
"browser_processing": 777
},
"visual_metrics": {
"fcp": 1154
}
},
"all_runs": [
{
"navigation_timings": {
"dns_lookup": 0,
"tcp_connect": 40,
"ttfb": 106,
"response": 129,
"dom_processing": 862,
"on_load": 1,
"page_load_time": 1589,
"browser_processing": 866
},
"visual_metrics": {
"fcp": 1214
}
},
{
"navigation_timings": {
"dns_lookup": 0,
"tcp_connect": 40,
"ttfb": 100,
"response": 124,
"dom_processing": 833,
"on_load": 0,
"page_load_time": 1556,
"browser_processing": 837
},
"visual_metrics": {
"fcp": 1147
}
},
{
"navigation_timings": {
"dns_lookup": 0,
"tcp_connect": 44,
"ttfb": 101,
"response": 130,
"dom_processing": 775,
"on_load": 0,
"page_load_time": 1480,
"browser_processing": 777
},
"visual_metrics": {
"fcp": 1154
}
},
{
"navigation_timings": {
"dns_lookup": 0,
"tcp_connect": 39,
"ttfb": 96,
"response": 138,
"dom_processing": 902,
"on_load": 0,
"page_load_time": 1625,
"browser_processing": 905
},
"visual_metrics": {
"fcp": 771
}
},
{
"navigation_timings": {
"dns_lookup": 0,
"tcp_connect": 42,
"ttfb": 128,
"response": 138,
"dom_processing": 782,
"on_load": 0,
"page_load_time": 1608,
"browser_processing": 784
},
"visual_metrics": {
"fcp": 1217
}
}
],
"os": "ios",
"os_version": "14",
"cpu_memory_power": null,
"browser_name": "safari",
"device": "iPhone XS"
},
{
"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
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!