Downloading Historical Flat Files
To download historical flat files, you will need a set of AWS credentials that provide access to the S3 bucket where the data is stored. These credentials are separate from your API credentials and are used exclusively for backfilling historical data.
Below is a python Script to help you get started.
import boto3
saving_path = "./20250101_token_unlock_event_sample.csv" # change path or filename here
file_uri = "the-tie-flat-files/unlocks_sample/20250101_token_unlock_event_sample.csv"
def download_file(file_uri, local_file_path, aws_access_key_id, aws_secret_access_key):
"""Downloads the file at the specified URI to the local file path.
Args:
file_uri (str): The URI of the file to download.
local_file_path (str): The path to the local file to save the download to.
aws_access_key_id (str): Your AWS access key ID.
aws_secret_access_key (str): Your AWS secret access key.
"""
session = boto3.Session(aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key)
s3 = session.resource('s3')
bucket, key = file_uri.split('/', maxsplit=1)
s3.Bucket(bucket).download_file(key, local_file_path)
AWS_ACCESS_KEY_ID = "<INSERT_KEY>"
AWS_SECRET_ACCESS_KEY = "<INSERT_KEY>"
download_file(file_uri, saving_path, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)