Learn boto3

The AWS SDK for Python: call S3, DynamoDB, SQS and every other AWS API

17 lessons · 3 hours · 4 levels · covers boto3 1.43

boto3 is Amazon's official Python SDK, built on botocore, giving Python code access to every AWS service through generated clients. It's how Python applications, scripts, data pipelines and Lambda functions store files in S3, read DynamoDB tables, send queue messages and automate infrastructure. Using it well means understanding credentials, pagination, errors, retries and the service-specific gotchas.

Before you start

boto3 builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics5 lessons · 50 min in total
2. PracticalUse it productively at work, with the usual idioms10 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs14 lessons · 3 hours in total
4. ExpertInternals and the edge cases experts know17 lessons · 3 hours in total

The boto3 tree

boto3Installing boto3 and configuring credentialsInstalling boto3 andconfiguring credent…Clients vs resourcesClients vs resourcesSessions, profiles and regionsSessions, profilesand regionsS3: upload, download and read objectsS3: upload, downloadand read objectsHandling errors: ClientError and friendsHandling errors:ClientError and frie…Paginators and waitersPaginators andwaitersDynamoDB with boto3DynamoDB withboto3SQS: sending and receiving messagesSQS: sending andreceiving messagesPresigned URLs for S3Presigned URLs forS3Testing boto3 code with moto and StubberTesting boto3 codewith moto and Stub…Virtual environments and pipVirtual environmentsand pipExceptions in depthExceptions in depthTesting with pytest and unittestTesting with pytestand unittest
Essentials and Practical shown (10 of 17 lessons); the full list is below. Click a lesson to read it.

All 17 lessons, in order

Getting started

  1. Installing boto3 and configuring credentials · Essentials · 10 min

    Install boto3, configure credentials and a region with the AWS CLI, profiles or environment variables, and verify who you are.

  2. Clients vs resources · Essentials · 10 min

    Understand low-level clients (one method per API operation, dict responses) versus the higher-level, feature-frozen resource API.

  3. Sessions, profiles and regions · Essentials · 8 min

    Use boto3.Session to work with specific profiles, regions or credentials, and create clients from it.

  4. Handling errors: ClientError and friends · Essentials · 10 min

    Catch botocore ClientError, read the AWS error code, use modeled exceptions like client.exceptions.NoSuchKey, and tell service from client-side errors.

Working with S3

  1. S3: upload, download and read objects · Essentials · 12 min

    Store and fetch S3 objects with put_object, get_object, upload_file and download_file, and list keys.

  2. Presigned URLs for S3 · Practical · 10 min

    Let browsers and other clients download or upload S3 objects directly with time-limited presigned URLs and POST policies.

  3. Large transfers, multipart and progress · Advanced · 12 min

    Tune managed S3 transfers with TransferConfig, track progress with callbacks, and understand multipart upload behavior and costs.

Pagination, testing and tuning

  1. Paginators and waiters · Practical · 10 min

    Iterate over all results with paginators, filter with JMESPath search(), and wait for resource states with waiters.

  2. Testing boto3 code with moto and Stubber · Practical · 12 min

    Test AWS code without AWS: moto's mock_aws for realistic in-memory services, and botocore's Stubber for exact request/response checks.

  3. Config: retries, timeouts and endpoints · Advanced · 12 min

    Tune clients with botocore Config: retry mode and attempts, connect and read timeouts, connection pool size, and custom endpoints.

  4. Concurrency: threads, clients and sessions · Advanced · 10 min

    Use boto3 safely from multiple threads: share clients, not sessions or resources, size the connection pool, and parallelize I/O-bound calls.

DynamoDB and SQS

  1. DynamoDB with boto3 · Practical · 14 min

    Read and write DynamoDB items with the Table resource: put_item, get_item, query with Key conditions, conditional writes and Decimal numbers.

  2. SQS: sending and receiving messages · Practical · 12 min

    Send, receive and delete SQS messages correctly with long polling, visibility timeouts and batches.

Roles and credentials

  1. Assuming roles with STS · Advanced · 12 min

    Get temporary credentials for another role or account with sts.assume_role, and let profiles refresh them automatically.

  2. The credential provider chain in depth · Expert · 12 min

    Exactly how botocore resolves and refreshes credentials: provider order, profiles, SSO and process providers, container and instance metadata, and caching.

Internals and scale

  1. How botocore works: models and events · Expert · 14 min

    Look inside botocore: JSON service models, dynamically generated clients, the request lifecycle and the event system for hooks.

  2. High-throughput patterns: batching and async · Expert · 12 min

    Scale AWS workloads with batch APIs (DynamoDB batch_writer, SQS batches), client reuse, pool sizing and async clients.