Skip to content

browserstack-clientReadme | 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

ParameterTypeDescription
options?BrowserStackOptionsOptional configuration options for the client.

Returns

ScreenshotsClient

Overrides

APIClient.constructor

Source

src/screenshots.ts:25

Methods

getBrowsers()

getBrowsers(options?): Promise<Object & Object[]>

Retrieves the list of available browsers for taking screenshots.

Parameters

ParameterTypeDescription
options?FetchOptions<Object>Optional fetch options for the request.

Returns

Promise<Object & Object[]>

A promise that resolves to the response from the API.

Source

src/screenshots.ts:37


createJob()

createJob(body, options?): Promise<Object>

Creates a new screenshots job.

Parameters

ParameterTypeDescription
bodyObjectThe request body for creating the job.
body.browsersObject[]-
body.orientation?"portrait" | "landscape"Description
Screen orientation for a mobile device. Default: portrait
body.url?stringExample
https://nextjs-template.vercel.app/
body.callback_url?stringDescription
Public URL to which the screenshot will be posted.
body.win_res?stringDescription
Sceen resolution of the Windows machine. Values: 1024x768, 1280x1024. Default: 1024x768

Example
1024x768
body.mac_res?stringDescription
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?booleanDescription
Set to true if URL is local and a Local Testing connection has been set up. Default: false
body.wait_time?numberDescription
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.

MemberTypeValueDescription
job_idstring-Description
Unique identifier for the screenshot job.

Example
4207442b2b0567368956dba064c22a3235a76214
callback_urlstring-Description
Public URL to which the screenshot will be posted.

Example
https://callback.example.com
win_resstring-Description
Sceen resolution of the Windows machine. Values: 1024x768, 1280x1024. Default: 1024x768

Example
1024x768
mac_resstring-Description
Sceen resolution of the Mac machine. Values: 1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080. Default: 1024x768

Example
1024x768
quality"Compressed" | "Original"-Description
Quality of the screenshot. Default: Compressed
wait_timenumber-Description
Time in seconds to wait before taking the screenshot. Default: 5

Example
5
orientation"portrait" | "landscape"-Description
Screen orientation for a mobile device. Default: portrait
screenshotsObject & Object | Object & Object[]--
idstringjob.job_id-

Source

src/screenshots.ts:47


getJob()

getJob(jobId, options?): Promise<Object>

Retrieves the details of a screenshots job.

Parameters

ParameterTypeDescription
jobIdstringThe 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.

MemberTypeValueDescription
job_idstring-Description
Unique identifier for the screenshot job.

Example
4207442b2b0567368956dba064c22a3235a76214
callback_urlstring-Description
Public URL to which the screenshot will be posted.

Example
https://callback.example.com
win_resstring-Description
Sceen resolution of the Windows machine. Values: 1024x768, 1280x1024. Default: 1024x768

Example
1024x768
mac_resstring-Description
Sceen resolution of the Mac machine. Values: 1024x768, 1280x960, 1280x1024, 1600x1200, 1920x1080. Default: 1024x768

Example
1024x768
quality"Compressed" | "Original"-Description
Quality of the screenshot. Default: Compressed
wait_timenumber-Description
Time in seconds to wait before taking the screenshot. Default: 5

Example
5
orientation"portrait" | "landscape"-Description
Screen orientation for a mobile device. Default: portrait
screenshotsObject & Object | Object & Object[]--
state"done" | "queued_all"-Description
State of the screenshot job.

Example
done @enum {string}
idstring--

Source

src/screenshots.ts:66


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

ParameterTypeDefault valueDescription
jobIdstringundefinedThe ID of the job to track.
onScreenshot?(screenshot) => void | Promise<void>undefinedOptional callback function that will be called when a new screenshot is added to the result.
options?APIFetchOptions<Object>undefined-
pollInterval?number10_000The 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

src/screenshots.ts:91


launch()

launch(body, onScreenshot?, options?): Promise<Object & Object | Object & Object[]>

Launches a screenshots job with the specified parameters.

Parameters

ParameterTypeDescription
bodyObjectThe request body for creating the screenshots job.
body.browsersObject[]-
body.orientation?"portrait" | "landscape"Description
Screen orientation for a mobile device. Default: portrait
body.url?stringExample
https://nextjs-template.vercel.app/
body.callback_url?stringDescription
Public URL to which the screenshot will be posted.
body.win_res?stringDescription
Sceen resolution of the Windows machine. Values: 1024x768, 1280x1024. Default: 1024x768

Example
1024x768
body.mac_res?stringDescription
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?booleanDescription
Set to true if URL is local and a Local Testing connection has been set up. Default: false
body.wait_time?numberDescription
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> & ObjectOptional 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.

Source

src/screenshots.ts:156