Skip to content

Examples#

Index > APIGateway > Examples

Auto-generated documentation for APIGateway type annotations stubs module mypy-boto3-apigateway.

Client#

Implicit type annotations#

Can be used with boto3-stubs[apigateway] package installed.

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

# APIGatewayClient usage example

from boto3.session import Session


session = Session()

client = session.client("apigateway")  # (1)
result = client.create_api_key()  # (2)
  1. client: APIGatewayClient
  2. result: ApiKeyResponseTypeDef
# GetApiKeysPaginator usage example

from boto3.session import Session


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

paginator = client.get_paginator("get_api_keys")  # (2)
for item in paginator.paginate(...):
    print(item)  # (3)
  1. client: APIGatewayClient
  2. paginator: GetApiKeysPaginator
  3. item: ApiKeysTypeDef

Explicit type annotations#

With boto3-stubs-lite[apigateway] or a standalone mypy_boto3_apigateway package, you have to explicitly specify client: APIGatewayClient 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.

# APIGatewayClient usage example with type annotations

from boto3.session import Session

from mypy_boto3_apigateway.client import APIGatewayClient
from mypy_boto3_apigateway.type_defs import ApiKeyResponseTypeDef
from mypy_boto3_apigateway.type_defs import CreateApiKeyRequestRequestTypeDef


session = Session()

client: APIGatewayClient = session.client("apigateway")

kwargs: CreateApiKeyRequestRequestTypeDef = {...}
result: ApiKeyResponseTypeDef = client.create_api_key(**kwargs)
# GetApiKeysPaginator usage example with type annotations

from boto3.session import Session

from mypy_boto3_apigateway.client import APIGatewayClient
from mypy_boto3_apigateway.paginator import GetApiKeysPaginator
from mypy_boto3_apigateway.type_defs import ApiKeysTypeDef


session = Session()
client: APIGatewayClient = session.client("apigateway")

paginator: GetApiKeysPaginator = client.get_paginator("get_api_keys")
for item in paginator.paginate(...):
    item: ApiKeysTypeDef
    print(item)