List Sandboxes

Discover how to retrieve sandbox environments and navigate large result sets using pagination controls.

Using the TypeScript SDK

List all sandboxes in your account:

example.ts
import SandboxSDK from '@avmcodes/sandbox-sdk';

const client = new SandboxSDK({
  apiKey: process.env['SANDBOX_SDK_API_KEY'],
});

// List all sandboxes (first page)
const response = await client.sandboxes.list();

console.log(`Found ${response.pagination.total_items} sandboxes`);
response.data.forEach(sandbox => {
  console.log(`${sandbox.name} (${sandbox.id}) - Status: ${sandbox.status}`);
});

Basic Listing

Get the first page of sandboxes with default pagination:

basic-listing.ts
const response = await client.sandboxes.list();

// Access the sandboxes array
const sandboxes = response.data;

// Access pagination metadata
const { page, page_size, total_pages, total_items } = response.pagination;

console.log(`Page ${page} of ${total_pages}`);
console.log(`Showing ${sandboxes.length} of ${total_items} sandboxes`);

Custom Pagination

Specify page number and page size:

Iterating Through All Pages

Fetch all sandboxes by iterating through pages:

Filtering by Status

Filter sandboxes by their status:

Accessing Sandbox Details

Each sandbox object contains detailed information:

Counting Sandboxes

Get a quick count of your sandboxes:

Response Structure

The list() method returns a SandboxListResponse object:

Example Response

Sandbox Status

Sandboxes can have various statuses:

  • creating — Sandbox is being created

  • running — Sandbox is active and ready

  • stopped — Sandbox has been stopped

  • deleting — Sandbox is being deleted

Parameters

page number default:"1"

Page number to retrieve (starts at 1)

page_size number default:"28"

Number of items per page (1-100)

Response Fields

Data Array

Each item in the data array is a Sandbox object.

Pagination Object

The pagination object contains page, page_size, total_pages, and total_items.

Examples

Find a Specific Sandbox by Name

Get All Running Sandboxes

Monitor Sandbox Count

Best Practices

1

Use appropriate page sizes

Choose a page_size that balances between too many requests and too much data per request.

2

Cache pagination metadata

Cache total_items and total_pages to plan pagination without extra requests.

3

Handle empty results

Always check if the data array is empty before processing.

4

Respect rate limits

When iterating through pages, consider adding delays between requests if needed.

5

Filter client-side

Use client-side filtering for status or other properties rather than making multiple API calls.

Last updated