πŸ“ͺSet up S3 data retrieval

Here is sample code to retrieve data from Index One's S3 bucket in Python.

Step 1: Set up S3 delivery stream on Streams

Navigate to the Streams page and set up a delivery a stream with the below configurations.

Step 2: Retrieve data from the S3 bucket

Use this code to retrieve data from Index One's S3 bucket in Python.

Team directory is equal to the team_id which is accessible from the Team page in the console.

import boto3

access_key = "xxxxxxxxxxxxxxxxxxxx"
secret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
bucket_name = "prod-core-i1-export"
team_directory = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/"

session = boto3.Session(
    aws_access_key_id=access_key,
    aws_secret_access_key=secret
)

s3_client = session.client("s3")

r = s3_client.list_objects_v2(
    Bucket=bucket_name,
    Prefix=team_directory
)

for object in r['Contents']:
    s3_client.download_file(
        bucket_name,
        object['Key'],
        '/my/local/dir/filename.csv'
    )

Please get in touch with admin@indexone.io to request S3 access keys.

Last updated