Skip to main content
The get_screenshot method captures a screenshot of the current browser window and returns it as base64-encoded image data along with metadata. Unlike taking screenshots through the agent method (which saves files to disk), this method returns the screenshot data programmatically.
This method returns screenshot data directly in your code rather than saving it to disk. If you need screenshots saved automatically to your Downloads folder, use the agent method with a prompt like “take a screenshot of this page” instead.

Method Signature

async def get_screenshot(
    self,
    *,
    timeout: int | None = None,
) -> GetScreenshotResponse

Parameters

timeout
int | None
default:"None"
Maximum time in seconds to wait for the screenshot capture to complete. If None, uses the default system timeout.
timeout=30     # Wait up to 30 seconds
timeout=None   # Use default timeout

Return Value

Returns a GetScreenshotResponse object with the following structure:
base64_content
str
required
The screenshot image encoded as a base64 string. This can be decoded and saved to a file, displayed, or processed programmatically.
name
str
required
A suggested filename for the screenshot, typically in a format like “Screenshot 2026-01-14 at 10.54.54 AM”.
mime_type
str
required
The MIME type of the image format (e.g., “image/png”, “image/jpeg”).
timestamp
str
required
ISO 8601 formatted timestamp indicating when the screenshot was captured.

Example

import asyncio
import base64
from narada import Narada

async def main():
    async with Narada() as narada:
        window = await narada.open_and_initialize_browser_window()

        # Navigate to a page
        await window.go_to_url(url="https://example.com")

        # Capture a screenshot
        response = await window.get_screenshot()

        # Decode and save the screenshot
        image_data = base64.b64decode(response.base64_content)
        extension = response.mime_type.split('/')[1]  # "png" or "jpeg"
        filename = f"{response.name}.{extension}"

        with open(filename, "wb") as f:
            f.write(image_data)

        print(f"Screenshot saved as {filename}")
        print(f"Captured at: {response.timestamp}")

if __name__ == "__main__":
    asyncio.run(main())