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-aioboto3[apigatewayv2] package installed.

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

Client usage example
from aioboto3.session import Session


session = Session()

async with session.client("apigatewayv2") as client:  # (1)
    result = await client.create_api()  # (2)
  1. client: ApiGatewayV2Client
  2. result: CreateApiResponseTypeDef
Paginator usage example
from aioboto3.session import Session


session = Session()

async with session.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-aioboto3-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.

Client usage example
from aioboto3.session import 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 = Session()

client: ApiGatewayV2Client
async with session.client("apigatewayv2") as client:  # (1)
    kwargs: CreateApiRequestRequestTypeDef = {...}  # (2)
    result: CreateApiResponseTypeDef = await client.create_api(**kwargs)  # (3)
  1. client: ApiGatewayV2Client
  2. kwargs: CreateApiRequestRequestTypeDef
  3. result: CreateApiResponseTypeDef
Paginator usage example
from aioboto3.session import Session

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


session = Session()

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