Note
Event Notifications feature is now in Private Preview. See https://www.backblaze.com/blog/announcing-event-notifications/ for details.
Overview
b2sdk is a client library for easy access to all of the capabilities of B2 Cloud Storage.
B2 command-line tool is an example of how it can be used to provide command-line access to the B2 service, but there are many possible applications (including FUSE filesystems, storage backend drivers for backup applications etc).
Why use b2sdk?
When building an application which uses B2 cloud, it is possible to implement an independent B2 API client, but using b2sdk allows for:
reuse of code that is already written, with hundreds of unit tests
use of Synchronizer, a high-performance, parallel rsync-like utility
developer-friendly library api version policy which guards your program against incompatible changes
B2 integration checklist is passed automatically
raw_simulator makes it easy to mock the B2 cloud for unit testing purposes
reporting progress of operations to an object of your choice
exception hierarchy makes it easy to display informative messages to users
interrupted transfers are automatically continued
b2sdk has been developed for 3 years before it version 1.0.0 was released. It’s stable and mature.
Documentation index
- Installation Guide
- Tutorial
- Quick Start Guide
- Server-Side Encryption
- Advanced usage patterns
- Glossary
- About API interfaces
- API Reference
- Interface types
- Public API
- B2 Application key
- AccountInfo
- AccountInfo implementations
- InMemoryAccountInfo
- SqliteAccountInfo
SqliteAccountInfo
SqliteAccountInfo.__init__()
SqliteAccountInfo.get_user_account_info_path()
SqliteAccountInfo.clear()
SqliteAccountInfo.set_auth_data_with_schema_0_for_test()
SqliteAccountInfo.get_application_key()
SqliteAccountInfo.get_account_id()
SqliteAccountInfo.get_application_key_id()
SqliteAccountInfo.get_api_url()
SqliteAccountInfo.get_account_auth_token()
SqliteAccountInfo.get_download_url()
SqliteAccountInfo.get_realm()
SqliteAccountInfo.get_recommended_part_size()
SqliteAccountInfo.get_absolute_minimum_part_size()
SqliteAccountInfo.get_allowed()
SqliteAccountInfo.get_s3_api_url()
SqliteAccountInfo.refresh_entire_bucket_name_cache()
SqliteAccountInfo.save_bucket()
SqliteAccountInfo.remove_bucket_name()
SqliteAccountInfo.get_bucket_id_or_none_from_bucket_name()
SqliteAccountInfo.get_bucket_name_or_none_from_bucket_id()
SqliteAccountInfo.list_bucket_names_ids()
SqliteAccountInfo.BUCKET_UPLOAD_POOL_CLASS
SqliteAccountInfo.DEFAULT_ALLOWED
SqliteAccountInfo.LARGE_FILE_UPLOAD_POOL_CLASS
SqliteAccountInfo.all_capabilities()
SqliteAccountInfo.allowed_is_valid()
SqliteAccountInfo.clear_bucket_upload_data()
SqliteAccountInfo.clear_large_file_upload_urls()
SqliteAccountInfo.is_master_key()
SqliteAccountInfo.is_same_account()
SqliteAccountInfo.is_same_key()
SqliteAccountInfo.put_bucket_upload_url()
SqliteAccountInfo.put_large_file_upload_url()
SqliteAccountInfo.set_auth_data()
SqliteAccountInfo.take_bucket_upload_url()
SqliteAccountInfo.take_large_file_upload_url()
- Implementing your own
- AccountInfo interface
AbstractAccountInfo
AbstractAccountInfo.list_bucket_names_ids()
AbstractAccountInfo.DEFAULT_ALLOWED
AbstractAccountInfo._abc_impl
AbstractAccountInfo._set_auth_data()
AbstractAccountInfo.all_capabilities()
AbstractAccountInfo.allowed_is_valid()
AbstractAccountInfo.clear()
AbstractAccountInfo.clear_bucket_upload_data()
AbstractAccountInfo.clear_large_file_upload_urls()
AbstractAccountInfo.get_absolute_minimum_part_size()
AbstractAccountInfo.get_account_auth_token()
AbstractAccountInfo.get_account_id()
AbstractAccountInfo.get_allowed()
AbstractAccountInfo.get_api_url()
AbstractAccountInfo.get_application_key()
AbstractAccountInfo.get_application_key_id()
AbstractAccountInfo.get_bucket_id_or_none_from_bucket_name()
AbstractAccountInfo.get_bucket_name_or_none_from_bucket_id()
AbstractAccountInfo.get_download_url()
AbstractAccountInfo.get_realm()
AbstractAccountInfo.get_recommended_part_size()
AbstractAccountInfo.get_s3_api_url()
AbstractAccountInfo.is_master_key()
AbstractAccountInfo.is_same_account()
AbstractAccountInfo.is_same_key()
AbstractAccountInfo.put_bucket_upload_url()
AbstractAccountInfo.put_large_file_upload_url()
AbstractAccountInfo.refresh_entire_bucket_name_cache()
AbstractAccountInfo.remove_bucket_name()
AbstractAccountInfo.save_bucket()
AbstractAccountInfo.set_auth_data()
AbstractAccountInfo.take_bucket_upload_url()
AbstractAccountInfo.take_large_file_upload_url()
- AccountInfo helper classes
UrlPoolAccountInfo
UrlPoolAccountInfo.BUCKET_UPLOAD_POOL_CLASS
UrlPoolAccountInfo.LARGE_FILE_UPLOAD_POOL_CLASS
UrlPoolAccountInfo.clear()
UrlPoolAccountInfo.put_bucket_upload_url()
UrlPoolAccountInfo.clear_bucket_upload_data()
UrlPoolAccountInfo.take_bucket_upload_url()
UrlPoolAccountInfo.put_large_file_upload_url()
UrlPoolAccountInfo.take_large_file_upload_url()
UrlPoolAccountInfo.clear_large_file_upload_urls()
UrlPoolAccountInfo.DEFAULT_ALLOWED
UrlPoolAccountInfo.all_capabilities()
UrlPoolAccountInfo.allowed_is_valid()
UrlPoolAccountInfo.get_absolute_minimum_part_size()
UrlPoolAccountInfo.get_account_auth_token()
UrlPoolAccountInfo.get_account_id()
UrlPoolAccountInfo.get_allowed()
UrlPoolAccountInfo.get_api_url()
UrlPoolAccountInfo.get_application_key()
UrlPoolAccountInfo.get_application_key_id()
UrlPoolAccountInfo.get_bucket_id_or_none_from_bucket_name()
UrlPoolAccountInfo.get_bucket_name_or_none_from_bucket_id()
UrlPoolAccountInfo.get_download_url()
UrlPoolAccountInfo.get_realm()
UrlPoolAccountInfo.get_recommended_part_size()
UrlPoolAccountInfo.get_s3_api_url()
UrlPoolAccountInfo.is_master_key()
UrlPoolAccountInfo.is_same_account()
UrlPoolAccountInfo.is_same_key()
UrlPoolAccountInfo.list_bucket_names_ids()
UrlPoolAccountInfo.refresh_entire_bucket_name_cache()
UrlPoolAccountInfo.remove_bucket_name()
UrlPoolAccountInfo.save_bucket()
UrlPoolAccountInfo.set_auth_data()
UploadUrlPool
- AccountInfo interface
- AccountInfo implementations
- Cache
AbstractCache
AuthInfoCache
AuthInfoCache.__init__()
AuthInfoCache.get_bucket_id_or_none_from_bucket_name()
AuthInfoCache.get_bucket_name_or_none_from_bucket_id()
AuthInfoCache.get_bucket_name_or_none_from_allowed()
AuthInfoCache.list_bucket_names_ids()
AuthInfoCache.save_bucket()
AuthInfoCache.set_bucket_name_cache()
AuthInfoCache.clear()
DummyCache
InMemoryCache
InMemoryCache.__init__()
InMemoryCache.get_bucket_id_or_none_from_bucket_name()
InMemoryCache.get_bucket_name_or_none_from_bucket_id()
InMemoryCache.get_bucket_name_or_none_from_allowed()
InMemoryCache.list_bucket_names_ids()
InMemoryCache.save_bucket()
InMemoryCache.set_bucket_name_cache()
InMemoryCache.clear()
- B2 Api client
B2Api
B2Api.SESSION_CLASS
B2Api.BUCKET_CLASS
B2Api.BUCKET_FACTORY_CLASS
B2Api.SERVICES_CLASS
B2Api.FILE_VERSION_FACTORY_CLASS
B2Api.__init__()
B2Api.get_bucket_by_id()
B2Api.authorize_account()
B2Api.DEFAULT_LIST_KEY_COUNT
B2Api.DOWNLOAD_VERSION_FACTORY_CLASS
B2Api.account_info
B2Api.authorize_automatically()
B2Api.cache
B2Api.cancel_large_file()
B2Api.check_bucket_id_restrictions()
B2Api.check_bucket_name_restrictions()
B2Api.create_bucket()
B2Api.create_key()
B2Api.delete_bucket()
B2Api.delete_file_version()
B2Api.delete_key()
B2Api.delete_key_by_id()
B2Api.download_file_by_id()
B2Api.get_account_id()
B2Api.get_bucket_by_name()
B2Api.get_download_url_for_file_name()
B2Api.get_download_url_for_fileid()
B2Api.get_file_info()
B2Api.get_file_info_by_name()
B2Api.get_key()
B2Api.list_buckets()
B2Api.list_keys()
B2Api.list_parts()
B2Api.raw_api
B2Api.update_file_legal_hold()
B2Api.update_file_retention()
B2HttpApiConfig
- Exceptions
- B2 Bucket
Bucket
Bucket.FILE_VERSION_FACTORY_CLASS
Bucket.get_fresh_state()
Bucket.upload_bytes()
Bucket.upload_local_file()
Bucket.ls()
Bucket.DEFAULT_CONTENT_TYPE
Bucket.__init__()
Bucket.as_dict()
Bucket.cancel_large_file()
Bucket.concatenate()
Bucket.concatenate_stream()
Bucket.copy()
Bucket.create_file()
Bucket.create_file_stream()
Bucket.delete_file_version()
Bucket.download_file_by_id()
Bucket.download_file_by_name()
Bucket.get_download_authorization()
Bucket.get_download_url()
Bucket.get_file_info_by_id()
Bucket.get_file_info_by_name()
Bucket.get_id()
Bucket.get_notification_rules()
Bucket.hide_file()
Bucket.list_file_versions()
Bucket.list_parts()
Bucket.list_unfinished_large_files()
Bucket.set_info()
Bucket.set_notification_rules()
Bucket.set_type()
Bucket.unhide_file()
Bucket.update()
Bucket.upload()
Bucket.upload_unbound_stream()
- File locks
- Data classes
FileVersion
FileVersion.cache_control
FileVersion.as_dict()
FileVersion.ADVANCED_HEADERS_LIMIT
FileVersion.DEFAULT_HEADERS_LIMIT
FileVersion.account_id
FileVersion.action
FileVersion.api
FileVersion.bucket_id
FileVersion.content_disposition
FileVersion.content_encoding
FileVersion.content_language
FileVersion.content_md5
FileVersion.content_sha1
FileVersion.content_sha1_verified
FileVersion.content_type
FileVersion.delete()
FileVersion.download()
FileVersion.expires
FileVersion.expires_parsed()
FileVersion.file_info
FileVersion.file_name
FileVersion.file_retention
FileVersion.get_content_sha1()
FileVersion.get_fresh_state()
FileVersion.has_large_header
FileVersion.id_
FileVersion.legal_hold
FileVersion.mod_time_millis
FileVersion.replication_status
FileVersion.server_side_encryption
FileVersion.size
FileVersion.update_legal_hold()
FileVersion.update_retention()
FileVersion.upload_timestamp
DownloadVersion
DownloadVersion.range_
DownloadVersion.content_disposition
DownloadVersion.content_length
DownloadVersion.content_language
DownloadVersion.expires
DownloadVersion.cache_control
DownloadVersion.content_encoding
DownloadVersion.expires_parsed()
DownloadVersion.as_dict()
DownloadVersion.api
DownloadVersion.content_sha1
DownloadVersion.content_sha1_verified
DownloadVersion.content_type
DownloadVersion.delete()
DownloadVersion.file_info
DownloadVersion.file_name
DownloadVersion.file_retention
DownloadVersion.get_content_sha1()
DownloadVersion.id_
DownloadVersion.legal_hold
DownloadVersion.mod_time_millis
DownloadVersion.replication_status
DownloadVersion.server_side_encryption
DownloadVersion.size
DownloadVersion.update_legal_hold()
DownloadVersion.update_retention()
DownloadVersion.upload_timestamp
FileIdAndName
UnfinishedLargeFile
Part
Range
- Downloaded File
- Enums
- Progress reporters
- Synchronizer
- Sync Options
- Public API classes
ScanPoliciesManager
Synchronizer
SyncReport
SyncReport.update_compare()
SyncReport.end_compare()
SyncReport.update_transfer()
SyncReport.UPDATE_INTERVAL
SyncReport.__init__()
SyncReport.circular_symlink_skipped()
SyncReport.close()
SyncReport.end_total()
SyncReport.error()
SyncReport.has_errors_or_warnings()
SyncReport.invalid_name()
SyncReport.local_access_error()
SyncReport.local_permission_error()
SyncReport.print_completion()
SyncReport.symlink_skipped()
SyncReport.update_count()
SyncReport.update_total()
SyncReport.stdout
SyncReport.no_progress
- Sync Encryption Settings Providers
- B2 Utility functions
- Write intent
- Outbound Transfer Source
- Encryption Settings
- Encryption Types
- Internal API
b2sdk._internal.session
– B2 SessionTokenType
B2Session
B2Session.SQLITE_ACCOUNT_INFO_CLASS
B2Session.B2HTTP_CLASS
B2Session.__init__()
B2Session.authorize_automatically()
B2Session.authorize_account()
B2Session.cancel_large_file()
B2Session.create_bucket()
B2Session.create_key()
B2Session.delete_key()
B2Session.delete_bucket()
B2Session.delete_file_version()
B2Session.download_file_from_url()
B2Session.finish_large_file()
B2Session.get_download_authorization()
B2Session.get_file_info_by_id()
B2Session.get_file_info_by_name()
B2Session.get_upload_url()
B2Session.get_upload_part_url()
B2Session.hide_file()
B2Session.list_buckets()
B2Session.list_file_names()
B2Session.list_file_versions()
B2Session.list_keys()
B2Session.list_parts()
B2Session.list_unfinished_large_files()
B2Session.start_large_file()
B2Session.update_bucket()
B2Session.upload_file()
B2Session.upload_part()
B2Session.get_download_url_by_id()
B2Session.get_download_url_by_name()
B2Session.copy_file()
B2Session.copy_part()
B2Session.update_file_retention()
B2Session.update_file_legal_hold()
B2Session.get_bucket_notification_rules()
B2Session.set_bucket_notification_rules()
b2sdk._internal.raw_api
– B2 raw api wrapperMetadataDirectiveMode
LifecycleRule
NameValueDict
NotificationTargetConfiguration
NotificationRule
NotificationRuleResponse
notification_rule_response_to_request()
AbstractRawApi
AbstractRawApi.authorize_account()
AbstractRawApi.cancel_large_file()
AbstractRawApi.copy_file()
AbstractRawApi.copy_part()
AbstractRawApi.create_bucket()
AbstractRawApi.create_key()
AbstractRawApi.download_file_from_url()
AbstractRawApi.delete_key()
AbstractRawApi.delete_bucket()
AbstractRawApi.delete_file_version()
AbstractRawApi.finish_large_file()
AbstractRawApi.get_download_authorization()
AbstractRawApi.get_file_info_by_id()
AbstractRawApi.get_file_info_by_name()
AbstractRawApi.get_upload_url()
AbstractRawApi.get_upload_part_url()
AbstractRawApi.hide_file()
AbstractRawApi.list_buckets()
AbstractRawApi.list_file_names()
AbstractRawApi.list_file_versions()
AbstractRawApi.list_keys()
AbstractRawApi.list_parts()
AbstractRawApi.list_unfinished_large_files()
AbstractRawApi.start_large_file()
AbstractRawApi.update_bucket()
AbstractRawApi.update_file_retention()
AbstractRawApi.get_upload_file_headers()
AbstractRawApi.upload_file()
AbstractRawApi.upload_part()
AbstractRawApi.get_download_url_by_id()
AbstractRawApi.get_download_url_by_name()
AbstractRawApi.set_bucket_notification_rules()
AbstractRawApi.get_bucket_notification_rules()
B2RawHTTPApi
B2RawHTTPApi.__init__()
B2RawHTTPApi.authorize_account()
B2RawHTTPApi.cancel_large_file()
B2RawHTTPApi.create_bucket()
B2RawHTTPApi.create_key()
B2RawHTTPApi.delete_bucket()
B2RawHTTPApi.delete_file_version()
B2RawHTTPApi.delete_key()
B2RawHTTPApi.download_file_from_url()
B2RawHTTPApi.finish_large_file()
B2RawHTTPApi.get_download_authorization()
B2RawHTTPApi.get_file_info_by_id()
B2RawHTTPApi.get_file_info_by_name()
B2RawHTTPApi.get_upload_url()
B2RawHTTPApi.get_upload_part_url()
B2RawHTTPApi.hide_file()
B2RawHTTPApi.list_buckets()
B2RawHTTPApi.list_file_names()
B2RawHTTPApi.list_file_versions()
B2RawHTTPApi.list_keys()
B2RawHTTPApi.list_parts()
B2RawHTTPApi.list_unfinished_large_files()
B2RawHTTPApi.start_large_file()
B2RawHTTPApi.update_bucket()
B2RawHTTPApi.update_file_retention()
B2RawHTTPApi.update_file_legal_hold()
B2RawHTTPApi.check_b2_filename()
B2RawHTTPApi.upload_file()
B2RawHTTPApi.upload_part()
B2RawHTTPApi.copy_file()
B2RawHTTPApi.copy_part()
B2RawHTTPApi.set_bucket_notification_rules()
B2RawHTTPApi.get_bucket_notification_rules()
b2sdk._internal.b2http
– thin http client wrapperrandom()
setlocale()
ResponseContextManager
HttpCallback
ClockSkewHook
B2Http
B2Http.CONNECTION_TIMEOUT
B2Http.TIMEOUT
B2Http.TIMEOUT_FOR_COPY
B2Http.TIMEOUT_FOR_UPLOAD
B2Http.TRY_COUNT_DATA
B2Http.TRY_COUNT_DOWNLOAD
B2Http.TRY_COUNT_HEAD
B2Http.TRY_COUNT_OTHER
B2Http.add_callback()
B2Http.request()
B2Http.request_content_return_json()
B2Http.post_content_return_json()
B2Http.post_json_return_json()
B2Http.get_content()
B2Http.head_content()
NotDecompressingHTTPAdapter
b2sdk._internal.requests
– modified requests.models.Response classb2sdk._internal.utils
b2_url_encode()
b2_url_decode()
choose_part_ranges()
update_digest_from_stream()
hex_sha1_of_stream()
IncrementalHexDigester
hex_sha1_of_unlimited_stream()
hex_sha1_of_file()
hex_sha1_of_bytes()
hex_md5_of_bytes()
md5_of_bytes()
b64_of_bytes()
validate_b2_file_name()
get_file_mtime()
is_special_file()
set_file_mtime()
fix_windows_path_limit()
format_and_scale_number()
format_and_scale_fraction()
camelcase_to_underscore()
B2TraceMeta
B2TraceMetaAbstract
ConcurrentUsedAuthTokenGuard
current_time_millis()
iterator_peek()
b2sdk._internal.cache
b2sdk._internal.stream.chained
ChainedStreamb2sdk._internal.stream.hashing
StreamWithHashb2sdk._internal.stream.progress
Streams with progress reportingb2sdk._internal.stream.range
RangeOfInputStreamb2sdk._internal.stream.wrapper
StreamWrapperb2sdk._internal.scan.folder_parser
b2sdk._internal.scan.folder
b2sdk._internal.scan.path
b2sdk._internal.scan.policies
b2sdk._internal.scan.scan
b2sdk._internal.sync.action
b2sdk._internal.sync.exception
b2sdk._internal.sync.policy
b2sdk._internal.sync.policy_manager
b2sdk._internal.sync.sync
b2sdk._internal.transfer.inbound.downloader.abstract
– Downloader base classb2sdk._internal.transfer.inbound.downloader.parallel
– ParallelTransfererb2sdk._internal.transfer.inbound.downloader.simple
– SimpleDownloaderb2sdk._internal.transfer.inbound.download_manager
– Manager of downloadersb2sdk._internal.transfer.outbound.upload_source
b2sdk._internal.raw_simulator
– B2 raw api simulatorget_bytes_range()
KeySimulator
PartSimulator
FileSimulator
FileSimulator.CHECK_ENCRYPTION
FileSimulator.SPECIAL_FILE_INFOS
FileSimulator.__init__()
FileSimulator.dont_check_encryption()
FileSimulator.sort_key()
FileSimulator.as_download_headers()
FileSimulator.as_upload_result()
FileSimulator.as_list_files_dict()
FileSimulator.is_allowed_to_read_file_retention()
FileSimulator.is_allowed_to_read_file_legal_hold()
FileSimulator.as_start_large_file_result()
FileSimulator.add_part()
FileSimulator.finish()
FileSimulator.is_visible()
FileSimulator.list_parts()
FileSimulator.check_encryption()
FakeRequest
FakeRaw
FakeResponse
BucketSimulator
BucketSimulator.FIRST_FILE_NUMBER
BucketSimulator.FIRST_FILE_ID
BucketSimulator.FILE_SIMULATOR_CLASS
BucketSimulator.RESPONSE_CLASS
BucketSimulator.MAX_SIMPLE_COPY_SIZE
BucketSimulator.__init__()
BucketSimulator.get_file()
BucketSimulator.is_allowed_to_read_bucket_encryption_setting()
BucketSimulator.is_allowed_to_read_bucket_retention()
BucketSimulator.bucket_dict()
BucketSimulator.cancel_large_file()
BucketSimulator.delete_file_version()
BucketSimulator.download_file_by_id()
BucketSimulator.download_file_by_name()
BucketSimulator.finish_large_file()
BucketSimulator.get_file_info_by_id()
BucketSimulator.get_file_info_by_name()
BucketSimulator.get_upload_url()
BucketSimulator.get_upload_part_url()
BucketSimulator.hide_file()
BucketSimulator.update_file_retention()
BucketSimulator.update_file_legal_hold()
BucketSimulator.copy_file()
BucketSimulator.list_file_names()
BucketSimulator.list_file_versions()
BucketSimulator.list_parts()
BucketSimulator.list_unfinished_large_files()
BucketSimulator.start_large_file()
BucketSimulator.upload_file()
BucketSimulator.upload_part()
BucketSimulator.get_notification_rules()
BucketSimulator.set_notification_rules()
BucketSimulator.simulate_notification_rule_suspension()
RawSimulator
RawSimulator.BUCKET_SIMULATOR_CLASS
RawSimulator.API_URL
RawSimulator.S3_API_URL
RawSimulator.DOWNLOAD_URL
RawSimulator.MIN_PART_SIZE
RawSimulator.MAX_PART_ID
RawSimulator.MAX_DURATION_IN_SECONDS
RawSimulator.UPLOAD_PART_MATCHER
RawSimulator.UPLOAD_URL_MATCHER
RawSimulator.DOWNLOAD_URL_MATCHER
RawSimulator.__init__()
RawSimulator.expire_auth_token()
RawSimulator.create_account()
RawSimulator.set_upload_errors()
RawSimulator.authorize_account()
RawSimulator.cancel_large_file()
RawSimulator.create_bucket()
RawSimulator.create_key()
RawSimulator.delete_file_version()
RawSimulator.update_file_retention()
RawSimulator.update_file_legal_hold()
RawSimulator.delete_bucket()
RawSimulator.download_file_from_url()
RawSimulator.delete_key()
RawSimulator.finish_large_file()
RawSimulator.get_download_authorization()
RawSimulator.get_file_info_by_id()
RawSimulator.get_file_info_by_name()
RawSimulator.get_upload_url()
RawSimulator.get_upload_part_url()
RawSimulator.hide_file()
RawSimulator.copy_file()
RawSimulator.copy_part()
RawSimulator.list_buckets()
RawSimulator.list_file_names()
RawSimulator.list_file_versions()
RawSimulator.list_keys()
RawSimulator.list_parts()
RawSimulator.list_unfinished_large_files()
RawSimulator.start_large_file()
RawSimulator.update_bucket()
RawSimulator.get_upload_file_headers()
RawSimulator.upload_file()
RawSimulator.upload_part()
RawSimulator.set_bucket_notification_rules()
RawSimulator.get_bucket_notification_rules()
- Contributors Guide