Skip to main content

MinIO Python Client SDK for Amazon S3 Compatible Cloud Storage Slack Apache V2 License

The MinIO Python Client SDK provides high level APIs to access any MinIO Object Storage or other Amazon S3 compatible service.

This Quickstart Guide covers how to install the MinIO client SDK, connect to the object storage service, and create a sample file uploader.

The example below uses:

The play server is a public MinIO cluster located at https://play.min.io. This cluster runs the latest stable version of MinIO and may be used for testing and development. The access credentials in the example are open to the public and all data uploaded to play should be considered public and world-readable.

For a complete list of APIs and examples, see the Python Client API Reference

Install the MinIO Python SDK

The Python SDK requires Python version 3.7+. You can install the SDK with pip or from the minio/minio-py GitHub repository:

Using pip

pip3 install minio

Using Source From GitHub

git clone https://github.com/minio/minio-py
cd minio-py
python setup.py install

Create a MinIO Client

To connect to the target service, create a MinIO client using the Minio() method with the following required parameters:

Parameter Description
endpoint URL of the target service.
access_key Access key (user ID) of a user account in the service.
secret_key Secret key (password) for the user account.

For example:

from minio import Minio

client = Minio("play.min.io",
    access_key="Q3AM3UQ867SPQQA43P2F",
    secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
)

Example - File Uploader

This example does the following:

  • Connects to the MinIO play server using the provided credentials.
  • Creates a bucket named python-test-bucket if it does not already exist.
  • Uploads a file named test-file.txt from /tmp, renaming it my-test-file.txt.
  • Verifies the file was created using mc ls.

file_uploader.py

# file_uploader.py MinIO Python SDK example
from minio import Minio
from minio.error import S3Error

def main():
    # Create a client with the MinIO server playground, its access key
    # and secret key.
    client = Minio("play.min.io",
        access_key="Q3AM3UQ867SPQQA43P2F",
        secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
    )

    # The file to upload, change this path if needed
    source_file = "/tmp/test-file.txt"

    # The destination bucket and filename on the MinIO server
    bucket_name = "python-test-bucket"
    destination_file = "my-test-file.txt"
    
    # Make the bucket if it doesn't exist.
    found = client.bucket_exists(bucket_name)
    if not found:
        client.make_bucket(bucket_name)
        print("Created bucket", bucket_name)
    else:
        print("Bucket", bucket_name, "already exists")

    # Upload the file, renaming it in the process
    client.fput_object(
        bucket_name, destination_file, source_file,
    )
    print(
        source_file, "successfully uploaded as object",
        destination_file, "to bucket", bucket_name,
    )

if __name__ == "__main__":
    try:
        main()
    except S3Error as exc:
        print("error occurred.", exc)

To run this example:

  1. Create a file in /tmp named test-file.txt. To use a different path or filename, modify the value of source_file.

  2. Run file_uploader.py with the following command:

python file_uploader.py

If the bucket does not exist on the server, the output resembles the following:

Created bucket python-test-bucket
/tmp/test-file.txt successfully uploaded as object my-test-file.txt to bucket python-test-bucket
  1. Verify the uploaded file with mc ls:
mc ls play/python-test-bucket
[2023-11-03 22:18:54 UTC]  20KiB STANDARD my-test-file.txt

More References

Explore Further

Contribute

Contributors Guide

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE and NOTICE for more information.

PYPI

Release files for minio 7.2.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minio 7.2.15
File Size Uploaded
minio-7.2.15.tar.gz 138.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for minio 7.2.15
File Interpreter ABI Platform
minio-7.2.15-py3-none-any.whl Python 3 none any Details

Total release size: 233.1 kB

Release files / minio-7.2.15.tar.gz

Download URL minio-7.2.15.tar.gz
Size 138.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5247df5d4dca7bfa4c9b20093acd5ad43e82d8710ceb059d79c6eea970f49f79
BLAKE2b-256 checksum
How to use checksums
9e6886a1cef80396e6a35a6fc4fafee5d28578c1a137bddd3ca2aa86f9b26a22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.12

Release files / minio-7.2.15-py3-none-any.whl

Download URL minio-7.2.15-py3-none-any.whl
Size 95.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c06ef7a43e5d67107067f77b6c07ebdd68733e5aa7eed03076472410ca19d876
BLAKE2b-256 checksum
How to use checksums
fb6f3690028e846fe432bfa5ba724a0dc37ec9c914965b7733e19d8ca2c4c48d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.12

Release history Release notifications | RSS feed

7.2.20

2 release files

7.2.19

2 release files

7.2.18

2 release files

7.2.17

2 release files

7.2.16

2 release files

This release

7.2.15 This release

2 release files

7.2.13

2 release files

7.2.12

2 release files

7.2.11

2 release files

7.2.10

2 release files

7.2.9

2 release files

7.2.8

2 release files

7.2.7

2 release files

7.2.6

2 release files

7.2.5

2 release files

7.2.4

2 release files

7.2.3

2 release files

7.2.2

2 release files

7.2.1

2 release files

7.2.0

2 release files

7.1.17

2 release files

7.1.16

2 release files

7.1.15

2 release files

7.1.14

2 release files

7.1.12

2 release files

7.1.11

2 release files

7.1.9

2 release files

7.1.8

2 release files

7.1.7

2 release files

7.1.6

2 release files

7.1.5

2 release files

7.1.4

2 release files

7.1.3

2 release files

7.1.2

2 release files

7.1.1

2 release files

7.1.0

2 release files

7.0.4

2 release files

7.0.3

2 release files

7.0.2

2 release files

7.0.1

2 release files

7.0.0

2 release files

6.0.2

3 release files

6.0.1

3 release files

6.0.0

3 release files

5.0.10

3 release files

5.0.9

3 release files

5.0.8

3 release files

5.0.7

3 release files

5.0.6

3 release files

5.0.5

3 release files

5.0.4

2 release files

5.0.3

3 release files

5.0.1

3 release files

5.0.0

3 release files

4.0.21

3 release files

4.0.20

3 release files

4.0.18

3 release files

4.0.17

3 release files

4.0.15

3 release files

4.0.14

3 release files

4.0.13

3 release files

4.0.12

3 release files

4.0.11

3 release files

4.0.10

3 release files

4.0.9

3 release files

4.0.8

3 release files

4.0.7

3 release files

4.0.6

3 release files

4.0.5

3 release files

4.0.4

3 release files

4.0.3

3 release files

4.0.2

3 release files

4.0.1

3 release files

4.0.0

3 release files

3.0.4

3 release files

3.0.3

3 release files

3.0.2

3 release files

3.0.1

3 release files

3.0.0

3 release files

2.2.6

4 release files

2.2.5

2 release files

2.2.4

2 release files

2.2.3

3 release files

2.2.2

3 release files

2.2.1

3 release files

2.2.0

3 release files

2.1.0

3 release files

2.0.8

3 release files

2.0.7

3 release files

2.0.6

3 release files

2.0.5

3 release files

2.0.4

3 release files

2.0.3

3 release files

2.0.2

3 release files

2.0.1

3 release files

2.0.0

3 release files

1.0.2

3 release files

1.0.1

3 release files

1.0.0

3 release files

0.2.9

3 release files

0.2.8

3 release files

0.2.6

3 release files

0.2.5

3 release files

0.2.4

3 release files

0.2.3

3 release files

0.2.2

3 release files

0.2.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page