Type annotations for boto3 IVS

1.42.3 · active · verified Sat Apr 11

mypy-boto3-ivs provides PEP 561 compatible type annotations for the `boto3` AWS IVS (Amazon Interactive Video Service) service, enhancing Python development with static type checking and IDE auto-completion. It is part of the `mypy-boto3-builder` project, which automatically generates and releases stub packages in sync with `boto3` updates. The current version is 1.42.3, mirroring the `boto3` version it types.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a typed IVS client using `boto3` and `mypy-boto3-ivs`, and then make a basic API call like `list_channels`. The `client: IVSClient` type hint ensures that type checkers (like Mypy or Pyright) provide accurate auto-completion and error checking for IVS-specific methods and response structures.

import boto3
from mypy_boto3_ivs.client import IVSClient
import os

# Ensure boto3 is configured, e.g., via environment variables or ~/.aws/credentials
# This example assumes credentials are set up for boto3

def get_ivs_channels():
    # The client will be implicitly typed as IVSClient due to mypy-boto3-ivs
    client: IVSClient = boto3.client("ivs", region_name=os.environ.get('AWS_REGION', 'us-east-1'))
    
    try:
        response = client.list_channels()
        print("Successfully listed IVS channels.")
        for channel in response.get("channels", []):
            print(f"  Channel ARN: {channel.get('arn')}, Name: {channel.get('name')}")
        return response.get("channels", [])
    except Exception as e:
        print(f"Error listing IVS channels: {e}")
        return []

if __name__ == "__main__":
    # Example usage
    ivs_channels = get_ivs_channels()
    if not ivs_channels:
        print("No IVS channels found or an error occurred.")

view raw JSON →