Node SDK Reference

steel-node

The Steel Node SDK provides a convenient way to interact with the Steel API for managing browser sessions and performing web-based tasks. This documentation covers the main functionalities grouped by session lifecycle management and browser tools.

InstallationCopied!

npm install steel-sdk

UsageCopied!

import Steel from 'steel-sdk';

const client = new Steel({
  steelAPIKey: process.env['STEEL_API_KEY'], // This is the default and can be omitted
});

Session LifecycleCopied!

Create a SessionCopied!

Creates a new browser session.

Method:

client.sessions.create(body?, options?): Promise<Session>

Endpoint:

POST /v1/sessions

Parameters:

  • SessionCreateParams:

    • concurrency?: number - Number of sessions to create concurrently (check your plan limit)

    • isSelenium?: boolean - Enable Selenium mode for the browser session (default is false)

    • proxyUrl?: string - Custom proxy URL for the browser session

    • sessionContext?: SessionContext - Session context data to be used in the created session

    • sessionId?: string - Optional custom UUID for the session

    • timeout?: number - Session timeout duration in milliseconds (default is 300000, 5 minutes)

    • solveCaptcha?: boolean - Enable automatic captcha solving (default is false)

    • useProxy?: boolean - Enable Steel-provided residential proxy usage (default is false)

    • userAgent?: string - Custom user agent string for the browser session

Response:

Session

Example:

const session = await client.sessions.create({
  useProxy: true,
  solveCaptcha: true,
  sessionTimeout: 1800000 // 30 minutes
});
console.log(session.id);

List SessionsCopied!

Retrieves a list of all active sessions.

Method:

client.sessions.list(query?, options?): SessionsCursor<SessionListResponse>

Endpoint:

GET /v1/sessions

Parameters:

  • SessionListParams:

    • cursorId?: string

    • limit?: number

    • status?: 'live' | 'released' | 'failed'

Response:

SessionListResponse

Example:

for await (const sessionListResponse of client.sessions.list()) {
  console.log(sessionListResponse.id);
}

Retrieve Session DetailsCopied!

Retrieves details of a specific session.

Method:

client.sessions.retrieve(id, options?): Promise<Session>

Endpoint:

GET /v1/sessions/{id}

Parameters:

  • id: string - Session ID

Response:

Session

Example:

const session = await client.sessions.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(session.id);

Get Session ContextCopied!

Fetches the context data of a specific session.

Method:

client.sessions.context(id, options?): Promise<SessionContext>

Endpoint:

GET /v1/sessions/{id}/context

Parameters:

  • id: string - Session ID

Response:

SessionContext

Example:

const sessionContext = await client.sessions.context('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(sessionContext.cookies);

Release a SessionCopied!

Releases a specific session.

Method:

client.sessions.release(id, options?): Promise<SessionReleaseResponse>

Endpoint:

POST /v1/sessions/{id}/release

Parameters:

  • id: string - Session ID

Response:

SessionReleaseResponse

Example:

const response = await client.sessions.release('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e');
console.log(response.message);

Release All SessionsCopied!

Releases all active sessions in your org.

Method:

client.sessions.releaseAll(options?): Promise<SessionReleaseAllResponse>

Endpoint:

POST /v1/sessions/release

Response:

SessionReleaseAllResponse

Example:

const response = await client.sessions.releaseAll();
console.log(response.message);