Skip to content

Examples#

Index > APIGateway > Examples

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

Client#

Implicit type annotations#

Can be used with types-boto3[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 types-boto3-lite[apigateway] or a standalone types_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 types_boto3_apigateway.client import APIGatewayClient
from types_boto3_apigateway.type_defs import ApiKeyResponseTypeDef
from types_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 types_boto3_apigateway.client import APIGatewayClient
from types_boto3_apigateway.paginator import GetApiKeysPaginator
from types_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)