Product 4 min read

Announcing Python SDK 2.0

The new Python SDK brings async support, better error handling, and a more Pythonic API. Here's what's new and how to upgrade.

Today we're releasing Python SDK 2.0, a major update that brings async/await support, improved error handling, and a more intuitive API design. Whether you're capturing a few screenshots or processing thousands, the new SDK makes it easier.

Async support

The most requested feature was async support. Now you can capture multiple screenshots concurrently without blocking:

import asyncio
from lambdashot import AsyncClient, TakeOptions

async def capture_multiple():
    client = AsyncClient('<access_key>', '<secret_key>')

    urls = [
        'https://example.com',
        'https://example.com/about',
        'https://example.com/pricing',
    ]

    tasks = [
        client.take(TakeOptions.url(url).format('png'))
        for url in urls
    ]

    screenshots = await asyncio.gather(*tasks)
    return screenshots

The async client uses aiohttp under the hood and works seamlessly with asyncio, FastAPI, and other async frameworks.

Better error handling

Version 2.0 introduces specific exception classes so you can handle different error cases appropriately:

from lambdashot import Client, TakeOptions
from lambdashot.exceptions import (
    RateLimitError,
    InvalidURLError,
    TimeoutError
)

client = Client('<access_key>', '<secret_key>')

try:
    image = client.take(TakeOptions.url('https://example.com'))
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except InvalidURLError:
    print("The URL is not valid or accessible")
except TimeoutError:
    print("The page took too long to load")

Type hints everywhere

The entire SDK is now fully typed, providing better IDE support and catching errors before runtime. Works great with mypy and Pyright.

Upgrading from 1.x

The upgrade is straightforward for most users:

  1. Update your dependency: pip install --upgrade lambdashot
  2. Replace Screenshot with TakeOptions
  3. Update exception handling if you were catching generic exceptions

Breaking changes

  • Screenshot class renamed to TakeOptions
  • capture() method renamed to take()
  • Minimum Python version is now 3.8

See the full Python SDK documentation for detailed examples and API reference.