Skip to content

Examples#

Index > ApiGatewayV2 > Examples

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

Client#

Implicit type annotations#

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

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

# ApiGatewayV2Client usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("apigatewayv2") as client:  # (1)
    result = await client.create_api()  # (2)
  1. client: ApiGatewayV2Client
  2. result: CreateApiResponseTypeDef
# GetApisPaginator usage example

from aiobotocore.session import get_session


session = get_session()

async with session.create_client("apigatewayv2") as client:  # (1)
    paginator = client.get_paginator("get_apis")  # (2)
    async for item in paginator.paginate(...):
        print(item)  # (3)
  1. client: ApiGatewayV2Client
  2. paginator: GetApisPaginator
  3. item: GetApisResponseTypeDef

Explicit type annotations#

With types-aiobotocore-lite[apigatewayv2] or a standalone types_aiobotocore_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 aiobotocore.session import get_session

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


session = get_session()

async with session.create_client("apigatewayv2") as client:
    client: ApiGatewayV2Client
    kwargs: CreateApiRequestRequestTypeDef = {...}
    result: CreateApiResponseTypeDef = await client.create_api(**kwargs)
# GetApisPaginator usage example with type annotations

from aiobotocore.session import get_session

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


session = get_session()

async with session.create_client("apigatewayv2") as client:
    client: ApiGatewayV2Client
    paginator: GetApisPaginator = client.get_paginator("get_apis")
    async for item in paginator.paginate(...):
        item: GetApisResponseTypeDef
        print(item)