[Python] Generate a presigned URL for an S3 object with Boto3

Created on November 30, 2026

You can use Boto3's generate_presigned_url() method to create a time-limited download URL for an S3 object. Use the bucket's AWS Region and credentials that have permission to read the object.

import boto3
from botocore.config import Config

s3 = boto3.client(
    "s3",
    region_name="ap-northeast-1",
    config=Config(signature_version="s3v4"),
)
url = s3.generate_presigned_url(
    "get_object",
    Params={"Bucket": "example-bucket", "Key": "reports/scores.txt"},
    ExpiresIn=3600,
)
print(url)

The script prints an HTTPS URL with a signature in its query string. ExpiresIn=3600 sets the requested lifetime to one hour. If the signing credentials expire sooner, the URL expires with them. Anyone who has the URL can use it while it is valid.

Python AWS