Skip to content

Examples#

Index > ApiGatewayV2 > Examples

Auto-generated documentation for ApiGatewayV2 type annotations stubs module types-boto3-apigatewayv2.

Client#

Implicit type annotations#

Can be used with types-boto3[apigatewayv2] package installed.

Write your ApiGatewayV2 code as usual, type checking and code completion should work out of the box.

# ApiGatewayV2Client usage example

from boto3.session import Session


session = Session()

client = session.client("apigatewayv2")  # (1)
result = client.create_api()  # (2)
  1. client: ApiGatewayV2Client
  2. result: CreateApiResponseTypeDef
# GetApisPaginator usage example

from boto3.session import Session


session = Session()
client = session.client("apigatewayv2")  # (1)

paginator = client.get_paginator("get_apis")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: ApiGatewayV2Client
  2. paginator: GetApisPaginator
  3. item: GetApisResponseTypeDef

Explicit type annotations#

With types-boto3-lite[apigatewayv2] or a standalone types_boto3_apigatewayv2 package, you have to explicitly specify client: ApiGatewayV2Client type annotation.

All other type annotations are optional, as types should be discovered automatically. However, these type annotations can be helpful in your functions and methods.

# ApiGatewayV2Client usage example with type annotations

from boto3.session import Session

from types_boto3_apigatewayv2.client import ApiGatewayV2Client
from types_boto3_apigatewayv2.type_defs import CreateApiResponseTypeDef
from types_boto3_apigatewayv2.type_defs import CreateApiRequestRequestTypeDef


session = Session()

client: ApiGatewayV2Client = session.client("apigatewayv2")

kwargs: CreateApiRequestRequestTypeDef = {...}
result: CreateApiResponseTypeDef = client.create_api(**kwargs)
# GetApisPaginator usage example with type annotations

from boto3.session import Session

from types_boto3_apigatewayv2.client import ApiGatewayV2Client
from types_boto3_apigatewayv2.paginator import GetApisPaginator
from types_boto3_apigatewayv2.type_defs import GetApisResponseTypeDef


session = Session()
client: ApiGatewayV2Client = session.client("apigatewayv2")

paginator: GetApisPaginator = client.get_paginator("get_apis")
for item in paginator.paginate(...):
    item: GetApisResponseTypeDef
    print(item)