How to use the AWS SDK for Python with B2. How to use the AWS SDK for Python with B2.

How to use the AWS SDK for Python with B2.

Troy Troy

The S3 Compatible API allows developers to interact with B2 Cloud Storage when using the AWS SDK for Python. The endpoint_url simply needs to be pointed to the S3 Endpoint of the Backblaze B2 account you are connecting to, along with supplying an Application Key and Key ID for the account.

 

Here is an example of doing so and creating a bucket:

 

import boto3

s3 = boto3.resource('s3',
endpoint_url = 'https://s3.us-west-002.backblazeb2.com',
aws_access_key_id = '<b2_keyId>',
aws_secret_access_key = '<b2_appKey>')

s3.create_bucket(Bucket='<BUCKET-NAME>')

 

Backblaze also maintains a Python SDK for the B2 Native API. You can find this project here: https://github.com/Backblaze/b2-sdk-python 

 

The S3 Compatible API for Backblaze B2 Cloud Storage allows 1000’s of integrations to work with B2 natively. If you’re new to the S3 Compatible API, please see our Getting Started Guide. If you have any trouble using the AWS SDK for Python with B2, please let us know by emailing us at b2feedback@backblaze.com.