Package: aiobotocore
Async client for amazon services usingbotocoreandaiohttp/asyncio.This library is a mostly full featured asynchronous version of botocore.Install$ pip install aiobotocoreBasic Exampleimportasynciofromaiobotocore.sessionimportget_sessionAWS_ACCESS_KEY_ID="xxx"AWS_SECRET_ACCESS_KEY="xxx"asyncdefgo():bucket='dataintake'filename='dummy.bin'folder='aiobotocore'key='{}/{}'.format(folder,filename)session=get_session()asyncwithsession.create_client('s3',region_name='us-west-2',aws_secret_access_key=AWS_SECRET_ACCESS_KEY,aws_access_key_id=AWS_ACCESS_KEY_ID)asclient:# upload object to amazon s3data=b'\x01'*1024resp=awaitclient.put_object(Bucket=bucket,Key=key,Body=data)print(resp)# getting s3 object properties of file we just uploadedresp=awaitclient.get_object_acl(Bucket=bucket,Key=key)print(resp)# get object from s3response=awaitclient.get_object(Bucket=bucket,Key=key)# this will ensure the connection is correctly re-used/closedasyncwithresponse['Body']asstream:assertawaitstream.read()==data# list s3 objects using paginatorpaginator=client.get_paginator('list_objects')asyncforresultinpaginator.paginate(Bucket=bucket,Prefix=folder):forcinresult.get('Contents',[]):print(c)# delete object from s3resp=awaitclient.delete_object(Bucket=bucket,Key=key)print(resp)loop=asyncio.get_event_loop()loop.run_until_complete(go())Context Manager ExamplesfromcontextlibimportAsyncExitStackfromaiobotocore.sessionimportAioSession# How to use in existing context managerclassManager:def__init__(self):self._exit_stack=AsyncExitStack()self._s3_client=Noneasyncdef__aenter__(self):session=AioSession()self._s3_client=awaitself._exit_stack.enter_async_context(session.create_client('s3'))asyncdef__aexit__(self,exc_type,exc_val,exc_tb):awaitself._exit_stack.__aexit__(exc_type,exc_val,exc_tb)# How to use with an external exit_stackasyncdefcreate_s3_client(session:AioSession,exit_stack:AsyncExitStack):# Create client and add cleanupclient=awaitexit_stack.enter_async_context(session.create_client('s3'))returnclientasyncdefnon_manager_example():session=AioSession()asyncwithAsyncExitStack()asexit_stack:s3_client=awaitcreate_s3_client(session,exit_stack)# do work with s3_clientSupported AWS ServicesThis is a non-exuastive list of what tests aiobotocore runs against AWS services. Not all methods are tested but we aim to test the majority of
commonly used methods.ServiceStatusS3WorkingDynamoDBBasic methods testedSNSBasic methods testedSQSBasic methods testedCloudFormationStack creation testedKinesisBasic methods testedDue to the way boto3 is implemented, its highly likely that even if services are not listed above that you can take anyboto3.client(‘service’)and
stickawaitinfront of methods to make them async, e.g.await client.list_named_queries()would asynchronous list all of the named Athena queries.If a service is not listed here and you could do with some tests or examples feel free to raise an issue.Run TestsThere are two set of tests, those that can be mocked throughmotorunning in docker, and those that require running against a personal amazon key. The CI only runs the moto tests.To run the moto tests:$ make mototestTo run the non-moto tests:Make sure you have development requirements installed and your amazon key and
secret accessible via environment variables:$ pip install pip-tools
$ pip-compile requirements-dev.txt
$ pip-sync requirements-dev.txt
$ export AWS_ACCESS_KEY_ID=xxx
$ export AWS_SECRET_ACCESS_KEY=xxxExecute tests suite:$ make testEnable type checking and code completionInstalltypes-aiobotocorethat contains type annotations foraiobotocoreand all supportedbotocoreservices.# install aiobotocore type annotations
# for ec2, s3, rds, lambda, sqs, dynamo and cloudformationpython-mpipinstall'types-aiobotocore[essential]'# or install annotations for services you usepython-mpipinstall'types-aiobotocore[acm,apigateway]'# Lite version does not provide session.create_client overloads
# it is more RAM-friendly, but requires explicit type annotationspython-mpipinstall'types-aiobotocore-lite[essential]'Now you should be able to runPylance,pyright, ormypyfor type checking
as well as code completion in your IDE.Fortypes-aiobotocore-litepackage use explicit type annotations:fromaiobotocore.sessionimportget_sessionfromtypes_aiobotocore_s3.clientimportS3Clientsession=get_session()asyncwithsession.create_client("s3")asclient:client:S3Client# type checking and code completion is now enabled for clientFull documentation fortypes-aiobotocorecan be found here:https://youtype.github.io/types_aiobotocore_docs/Mailing Listhttps://groups.google.com/forum/#!forum/aio-libsRequirementsPython3.8+aiohttpbotocoreawscli & boto3awscli and boto3 depend on a single version, or a narrow range of versions, of botocore.
However, aiobotocore only supports a specific range of botocore versions. To ensure you
install the latest version of awscli and boto3 that your specific combination or
aiobotocore and botocore can support use:pip install -U 'aiobotocore[awscli,boto3]'If you only need awscli and not boto3 (or vice versa) you can just install one extra or
the other.Changes2.12.0 (2024-02-28)bump botocore dependency specification2.11.2 (2024-02-02)bump botocore dependency specification2.11.1 (2024-01-25)bump botocore dependency specification2.11.0 (2024-01-19)send project-specificUser-AgentHTTP header #8532.10.0 (2024-01-18)bump botocore dependency specification2.9.1 (2024-01-17)fix race condition in S3 Express identity cache #10722.9.0 (2023-12-12)bump botocore dependency specification2.8.0 (2023-11-28)add AioStubber that returns AioAWSResponse()remove confusingaiobotocore.session.Sessionsymbolbump botocore dependency specification2.7.0 (2023-10-17)add support for Python 3.12drop more Python 3.7 support (EOL)relax botocore dependency specification2.6.0 (2023-08-11)bump aiohttp minimum version to 3.7.4.post0drop python 3.7 support (EOL)2.5.4 (2023-08-07)fix __aenter__ attribute error introduced in refresh bugfix (#1031)2.5.3 (2023-08-06)add more support for Python 3.11bump botocore to 1.31.17add waiter.wait returnfix SSO token refresh bug #10252.5.2 (2023-07-06)fix issue #10202.5.1 (2023-06-27)bump botocore to 1.29.1612.5.0 (2023-03-06)bump botocore to 1.29.76 (thanks @jakob-keller #999)2.4.2 (2022-12-22)fix retries (#988)2.4.1 (2022-11-28)Adds support for checksums in streamed request trailers (thanks @terrycain #962)2.4.0 (2022-08-25)bump botocore to 1.27.592.3.4 (2022-06-23)fix select_object_content2.3.3 (2022-06-07)fix connect timeout while getting IAM credsfix test files appearing in distribution package2.3.2 (2022-05-08)fix 3.6 testing and and actually fix 3.6 support2.3.1 (2022-05-06)fix 3.6 supportAioConfig: allow keepalive_timeout to be None (thanks @dnlserrano #933)2.3.0 (2022-05-05)fix encoding issue by swapping to AioAWSResponse and AioAWSRequest to behave more
like botocorefix exceptions mappings2.2.0 (2022-03-16)remove deprecated APIsbump to botocore 1.24.21re-enable retry of aiohttp.ClientPayloadError2.1.2 (2022-03-03)fix httpsession close call2.1.1 (2022-02-10)implement asynchronous non-blocking adaptive retry strategy2.1.0 (2021-12-14)bump to botocore 1.23.24fix aiohttp resolver config param #9062.0.1 (2021-11-25)revert accidental dupe of _register_s3_events #867 (thanks @eoghanmurray)Support customizing the aiohttp connector resolver class #893 (thanks @orf)fix timestream query #9022.0.0 (2021-11-02)bump to botocore 1.22.8turn off defaultAIOBOTOCORE_DEPRECATED_1_4_0_APISenv var to match botocore module.  See notes in 1.4.0.1.4.2 (2021-09-03)Fix missing close() method on http session (thanks@terrycain)Fix for verify=False1.4.1 (2021-08-24)put backwards incompatible changes behindAIOBOTOCORE_DEPRECATED_1_4_0_APISenv var.  This means that#876will not work unless this env var has been set to 0.1.4.0 (2021-08-20)fix retries via config#877remove AioSession and get_session top level names to matchbotocorechange exceptions raised to match those ofbotocore, seemappings1.3.3 (2021-07-12)fix AioJSONParser#8721.3.2 (2021-07-07)Bump tobotocoreto1.20.1061.3.1 (2021-06-11)TCPConnector: change deprecated ssl_context to sslfix non awaited generate presigned url calls#8681.3.0 (2021-04-09)Bump tobotocoreto1.20.49#8561.2.2 (2021-03-11)Await call to async method _load_creds_via_assume_role#858(thanks@puzza007)1.2.1 (2021-02-10)verify strings are now correctly passed to aiohttp.TCPConnector#851(thanks@FHTMitchell)1.2.0 (2021-01-11)bump botocore to1.19.52use passed in http_session_cls param to create_client#7971.1.2 (2020-10-07)fix AioPageIterator search method #831 (thanks@joseph-jones)1.1.1 (2020-08-31)fix s3 region redirect bug #8251.1.0 (2020-08-18)bump botocore to 1.17.441.0.7 (2020-06-04)fix generate_db_auth_token via #8161.0.6 (2020-06-04)revert __getattr__ fix as it breaks ddtrace1.0.5 (2020-06-03)Fixed AioSession.get_service_data emit call #811 via #812Fixed async __getattr__ #789 via #8031.0.4 (2020-04-15)Fixed S3 Presigned Post not being async1.0.3 (2020-04-09)Fixes typo when using credential process1.0.2 (2020-04-05)Disable Client.__getattr__ emit for now #7891.0.1 (2020-04-01)Fixed signing requests with explicit credentials1.0.0 (2020-03-31)API breaking: The result of create_client is now a required async context classCredential refresh should now workgenerate_presigned_url is now an async call along with other credential methodsCredentials.[access_key/secret_key/token] now raise NotImplementedError because
they won’t call refresh like botocore. Instead should use get_frozen_credentials
async methodBump botocore and extras0.12.0 (2020-02-23)Bump botocore and extrasDrop support for 3.5 given we are unable to test it with moto
and it will soon be unsupportedRemove loop parameters for Python 3.8 complianceRemove deprecated AioPageIterator.next_page0.11.1 (2020-01-03)Fixed event streaming API calls like S3 Select.0.11.0 (2019-11-12)replace CaseInsensitiveDict with urllib3 equivalent #744
(thanks to inspiration from @craigmccarter and @kevchentw)bump botocore to 1.13.14fix for mismatched botocore method replacements0.10.4 (2019-10-24)Make AioBaseClient.close method async #724 (thanks @bsitruk)Bump awscli, boto3, botocore #735 (thanks @bbrendon)switch paginator to async_generator, add result_key_iters
(deprecate next_page method)0.10.3 (2019-07-17)Bump botocore and extras0.10.2 (2019-02-11)Fix response-received emitted event #6820.10.1 (2019-02-08)Make tests pass with pytest 4.1 #669 (thanks @yan12125)Support Python 3.7 #671 (thanks to @yan12125)Update RTD build config #672 (thanks @willingc)Bump to botocore 1.12.91 #6790.10.0 (2018-12-09)Update to botocore 1.12.49 #639 (thanks @terrycain)0.9.4 (2018-08-08)Add ClientPayloadError as retryable exception0.9.3 (2018-07-16)Bring botocore up to date0.9.2 (2018-05-05)bump aiohttp requirement to fix read timeouts0.9.1 (2018-05-04)fix timeout bug introduced in last release0.9.0 (2018-06-01)bump aiohttp to 3.3.xremove unneeded set_socket_timeout0.8.0 (2018-05-07)Fix pagination #573 (thanks @adamrothman)Enabled several s3 tests via motoBring botocore up to date0.7.0 (2018-05-01)Just version bump0.6.1a0 (2018-05-01)bump to aiohttp 3.1.xswitch tests to Python 3.5+switch to native coroutinesfix non-streaming body timeout retries0.6.0 (2018-03-04)Upgrade to aiohttp>=3.0.0 #536 (thanks @Gr1N)0.5.3 (2018-02-23)Fixed waiters #523 (thanks @dalazx)fix conn_timeout #4850.5.2 (2017-12-06)Updated awscli dependency #4610.5.1 (2017-11-10)Disabled compressed response #4300.5.0 (2017-11-10)Fix error botocore error checking #190Update supported botocore requirement to: >=1.7.28, <=1.7.40Bump aiohttp requirement to support compressed responses correctly #2980.4.5 (2017-09-05)Added SQS examples and tests #336Changed requirements.txt structure #336bump to botocore 1.7.4Added DynamoDB examples and tests #3400.4.4 (2017-08-16)add the supported versions of boto3 to extras require #3240.4.3 (2017-07-05)add the supported versions of awscli to extras require #273 (thanks @graingert)0.4.2 (2017-07-03)update supported aiohttp requirement to: >=2.0.4, <=2.3.0update supported botocore requirement to: >=1.5.71, <=1.5.780.4.1 (2017-06-27)fix redirects #2680.4.0 (2017-06-19)update botocore requirement to: botocore>=1.5.34, <=1.5.70fix read_timeout due to #245implement set_socket_timeout0.3.3 (2017-05-22)switch to PEP 440 version parser to support ‘dev’ versions0.3.2 (2017-05-22)Fix botocore integrationProvisional fix for aiohttp 2.x stream supportupdate botocore requirement to: botocore>=1.5.34, <=1.5.520.3.1 (2017-04-18)Fixed Waiter support0.3.0 (2017-04-01)Added support for aiohttp>=2.0.4 (thanks @achimnol)update botocore requirement to: botocore>=1.5.0, <=1.5.330.2.3 (2017-03-22)update botocore requirement to: botocore>=1.5.0, <1.5.290.2.2 (2017-03-07)set aiobotocore.__all__ for * imports #121 (thanks @graingert)fix ETag in head_object response #1320.2.1 (2017-02-01)Normalize headers and handle redirection by botocore #115 (thanks @Fedorof)0.2.0 (2017-01-30)add support for proxies (thanks @jjonek)remove AioConfig verify_ssl connector_arg as this is handled by the
create_client verify paramremove AioConfig limit connector_arg as this is now handled by
by the Configmax_pool_connectionsproperty (note default is 10)0.1.1 (2017-01-16)botocore updated to version 1.5.00.1.0 (2017-01-12)Pass timeout to aiohttp.request to enforce read_timeout #86 (thanks @vharitonsky)
(bumped up to next semantic version due to read_timeout enabling change)0.0.6 (2016-11-19)Added enforcement of plain response #57 (thanks @rymir)botocore updated to version 1.4.73 #74 (thanks @vas3k)0.0.5 (2016-06-01)Initial alpha release