Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex DataSphere
  • Getting started
    • All guides
      • Connecting to S3 using boto3
      • Connecting to a ClickHouse® database
      • Connecting to a PostgreSQL database
      • Connecting to Yandex Disk
      • Connecting to Google Drive
    • Migrating a workflow to a new version
  • Terraform reference
  • Audit Trails events
  • Access management
  • Pricing policy
  • Public materials
  • Release notes
  1. Step-by-step guides
  2. Connecting to data sources
  3. Connecting to S3 using boto3

Connecting to S3 using boto3

Written by
Yandex Cloud
Updated at August 15, 2025
View in Markdown

Follow this guide to connect to an S3 object storage in Jupyter Notebook using boto3. To connect to an object storage, use an S3 connector:

Note

Avoid using your S3 storage in FUSE mode for buckets with single-layer (non-recursive) folders that contain many files, as this will significantly degrade storage performance.

To set up an S3 connection from the notebook code:

  1. Create secrets: token (with ID) and key_value (with a secret part of the static access key for the service account).

  2. Open the DataSphere project:

    1. Select the project in your community or on the DataSphere home page in the Recent projects tab.

    2. Click Open project in JupyterLab and wait for the loading to complete.
    3. Open the notebook tab.
  3. Import the libraries:

    import boto3
    import os
    from os import path
    
  4. Enter the name of your bucket in the storage:

    bucket_name = '<bucket_name>'
    
  5. Establish a connection:

    session = boto3.session.Session()
    
    ENDPOINT = "https://storage.yandexcloud.net"
    
    session = boto3.Session(
        aws_access_key_id=(os.environ['token']),
        aws_secret_access_key=(os.environ['key_value']),
        region_name="ru-central1",
    )
    
    s3 = session.client(
        "s3", endpoint_url=ENDPOINT)
    
  6. Enter the name of the bucket and retrieve a list of objects it contains:

    for key in s3.list_objects(Bucket='<bucket_name>')['Contents']:
        print(key['Key'])
    

Was the article helpful?

Previous
File storage operations
Next
Connecting to a ClickHouse® database
© 2026 Direct Cursus Technology L.L.C.