> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.airtop.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.airtop.ai/_mcp/server.

Convert a base64 encoded screenshot to binary data that can be saved to a file.

### Parameters

**`screenshotResponse`** `AiPromptResponse` — required

The response object from the `windows.screenshot` method of the Airtop client. This object contains the base64 encoded
screenshot data that needs to be processed.

---

### Returns

**`processedScreenshots`** `ProcessScreenshotsResponse[]` — required

An array of objects, each containing:

#### + Show 5 properties

**`success`** `boolean` — required

Indicates if the screenshot was processed successfully.

---

**`binaryData`** `Buffer` — required

The binary data of the screenshot, which can be saved to a file.

---

**`mimeType`** `string` — required

The MIME type of the screenshot, used to determine the file extension.

---

**`index`** `number` — required

The index of the screenshot in the batch.

---

**`error`** `string`

An error message if the processing failed.

---

---

### Node.js Example

**`Typescript`**

```typescript title="Typescript"
import fs from 'node:fs';
import { AirtopClient, processScreenshots } from '@airtop/sdk';

const client = new AirtopClient({ apiKey: AIRTOP_API_KEY });

const { data: session } = await client.sessions.create({
  configuration: {
    timeoutMinutes: 20,
  },
});

const window = await client.windows.create(session.data.id, {
  url: 'https://www.airtop.ai/',
});

const screenshotResponse = await client.windows.screenshot(session.data.id, window.data.windowId);
const processedScreenshots = await processScreenshots(screenshotResponse);

for (const screenshot of processedScreenshots) {
  if (screenshot.success && screenshot.binaryData && screenshot.mimeType) {
    const mimeType = screenshot.mimeType;
    const filename = `screenshot_${screenshot.index + 1}.${mimeType.split('/')[1]}`;
    fs.writeFileSync(filename, screenshot.binaryData);
  } else {
    console.error('Error processing screenshot', screenshot.error);
  }
}
```

### Python Example

**`Python`**

```python title="Python"
from airtop import Airtop, process_screenshots
import os

api_key = os.getenv('AIRTOP_API_KEY')
client = Airtop(api_key=api_key)

session = client.sessions.create()
window = client.windows.create(session.data.id, url="https://www.airtop.ai/")

response = client.windows.screenshot(session.data.id, window.data.windowId)
processed_screenshots = process_screenshots(response)

for result in processed_screenshots:
    if result.success and result.binary_data:
        mime_type = result.mime_type
        filename = f'screenshot_{result.index}.{mime_type.split("/")[1]}'
        with open(filename, 'wb') as file:
            file.write(result.binary_data)
    else:
        print(f"Failed to process screenshot {result.index}: {result.error}")
```

This guide provides examples of how to use the "process screenshots" helper function in both Node.js and Python, demonstrating the steps to take screenshots and process them effectively.