Appearance
browserstack-client • Readme | API
browserstack-client / ScreenshotsClient
Class: ScreenshotsClient
ScreenshotsClient represents a client for interacting with the BrowserStack Screenshots API.
Index
getBrowsers — Retrieves the list of available browsers for taking screenshots.
createJob — Creates a new screenshots job.
getJob — Retrieves the details of a screenshots job.
trackJob — Tracks the progress of a screenshot job and retrieves the screenshots associated with it.
launch — Launches a screenshots job with the specified parameters.
See
https://www.browserstack.com/screenshots/api
Extends
APIClient
Constructors
new ScreenshotsClient(options)
new ScreenshotsClient(
options
?):ScreenshotsClient
Constructs a new instance of the ScreenshotsClient class.
Parameters
Parameter | Type | Description |
---|---|---|
options ? | BrowserStackOptions | Optional configuration options for the client. |
Returns
Overrides
APIClient.constructor
Source
Methods
getBrowsers()
getBrowsers(
options
?):Promise
<Object
&Object
[]>
Retrieves the list of available browsers for taking screenshots.
Parameters
Parameter | Type | Description |
---|---|---|
options ? | FetchOptions <Object > | Optional fetch options for the request. |
Returns
Promise
<Object
& Object
[]>
A promise that resolves to the response from the API.
Source
createJob()
createJob(
body
,options
?):Promise
<Object
>
Creates a new screenshots job.
Parameters
Parameter | Type | Description |
---|---|---|
body | Object | The request body for creating the job. |
body.browsers | Object [] | - |
body.orientation ? | "portrait" | "landscape" | Description Screen orientation for a mobile device. Default: portrait |
body.url ? | string | Examplehttps://nextjs-template.vercel.app/ |
body.callback_url ? | string | Description Public URL to which the screenshot will be posted. |
body.win_res ? | string | Description Sceen resolution of the Windows machine. Values: 1024x768, 1280x1024. Default: 1024x768 Example 1024x768 |
body.mac_res ? | string | Description Sceen resolution of the Mac machine. Values: 1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080. Default: 1024x768 Example 1024x768 |
body.quality ? | "Compressed" | "Original" | Description Quality of the screenshot. Default: Compressed |
body.local ? | boolean | Description Set to true if URL is local and a Local Testing connection has been set up. Default: false |
body.wait_time ? | number | Description Time in seconds to wait before taking the screenshot. Default: 5 Example 5 |
options ? | APIFetchOptions <Object > | Optional fetch options for the request. |
Returns
Promise
<Object
>
A promise that resolves to the response from the API.
Member Type Value Description job_id
string
- Description
Unique identifier for the screenshot job.
Example4207442b2b0567368956dba064c22a3235a76214
callback_url
string
- Description
Public URL to which the screenshot will be posted.
Examplehttps://callback.example.com
win_res
string
- Description
Sceen resolution of the Windows machine. Values: 1024x768, 1280x1024. Default: 1024x768
Example1024x768
mac_res
string
- Description
Sceen resolution of the Mac machine. Values: 1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080. Default: 1024x768
Example1024x768
quality
"Compressed"
|"Original"
- Description
Quality of the screenshot. Default: Compressedwait_time
number
- Description
Time in seconds to wait before taking the screenshot. Default: 5
Example5
orientation
"portrait"
|"landscape"
- Description
Screen orientation for a mobile device. Default: portraitscreenshots
Object
&Object
|Object
&Object
[]- - id
string
job.job_id -
Source
getJob()
getJob(
jobId
,options
?):Promise
<Object
>
Retrieves the details of a screenshots job.
Parameters
Parameter | Type | Description |
---|---|---|
jobId | string | The ID of the job to retrieve. |
options ? | APIFetchOptions <Object > | Optional fetch options for the request. |
Returns
Promise
<Object
>
A promise that resolves to the response from the API.
Member Type Value Description job_id
string
- Description
Unique identifier for the screenshot job.
Example4207442b2b0567368956dba064c22a3235a76214
callback_url
string
- Description
Public URL to which the screenshot will be posted.
Examplehttps://callback.example.com
win_res
string
- Description
Sceen resolution of the Windows machine. Values: 1024x768, 1280x1024. Default: 1024x768
Example1024x768
mac_res
string
- Description
Sceen resolution of the Mac machine. Values: 1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080. Default: 1024x768
Example1024x768
quality
"Compressed"
|"Original"
- Description
Quality of the screenshot. Default: Compressedwait_time
number
- Description
Time in seconds to wait before taking the screenshot. Default: 5
Example5
orientation
"portrait"
|"landscape"
- Description
Screen orientation for a mobile device. Default: portraitscreenshots
Object
&Object
|Object
&Object
[]- - state
"done"
|"queued_all"
- Description
State of the screenshot job.
Exampledone @enum {string}
id
string
- -
Source
trackJob()
trackJob(
jobId
,onScreenshot
?,options
?,pollInterval
?):Promise
<Object
&Object
|Object
&Object
[]>
Tracks the progress of a screenshot job and retrieves the screenshots associated with it.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
jobId | string | undefined | The ID of the job to track. |
onScreenshot ? | (screenshot ) => void | Promise <void > | undefined | Optional callback function that will be called when a new screenshot is added to the result. |
options ? | APIFetchOptions <Object > | undefined | - |
pollInterval ? | number | 10_000 | The interval (in milliseconds) at which the job status should be polled. Default is 10000ms. |
Returns
Promise
<Object
& Object
| Object
& Object
[]>
A promise that resolves with an array of screenshots when the job is completed.
Source
launch()
launch(
body
,onScreenshot
?,options
?):Promise
<Object
&Object
|Object
&Object
[]>
Launches a screenshots job with the specified parameters.
Parameters
Parameter | Type | Description |
---|---|---|
body | Object | The request body for creating the screenshots job. |
body.browsers | Object [] | - |
body.orientation ? | "portrait" | "landscape" | Description Screen orientation for a mobile device. Default: portrait |
body.url ? | string | Examplehttps://nextjs-template.vercel.app/ |
body.callback_url ? | string | Description Public URL to which the screenshot will be posted. |
body.win_res ? | string | Description Sceen resolution of the Windows machine. Values: 1024x768, 1280x1024. Default: 1024x768 Example 1024x768 |
body.mac_res ? | string | Description Sceen resolution of the Mac machine. Values: 1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080. Default: 1024x768 Example 1024x768 |
body.quality ? | "Compressed" | "Original" | Description Quality of the screenshot. Default: Compressed |
body.local ? | boolean | Description Set to true if URL is local and a Local Testing connection has been set up. Default: false |
body.wait_time ? | number | Description Time in seconds to wait before taking the screenshot. Default: 5 Example 5 |
onScreenshot ? | (screenshot ) => void | Promise <void > | Optional callback function to be called when a screenshot is available. |
options ? | APIFetchOptions <Object > & Object | Optional options for the API fetch and job tracking, including pollInterval. |
Returns
Promise
<Object
& Object
| Object
& Object
[]>
A promise that resolves to the result of the job tracking.