Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

download_openicpsr-private.py - Download files from private openICPSR deposits

Description

This script authenticates with openICPSR and downloads all files from a private deposit as a ZIP archive, then extracts it to a local directory. It’s designed for downloading draft/unpublished deposits that require authentication and are not publicly accessible.

Usage

python3 tools/download_openicpsr-private.py PROJECT_ID [path] [login]

Arguments

Setup

You should normally have set up environment variables, see Setting up your Bash environment.

# Using environment variables for authentication
export ICPSR_EMAIL="your.email@domain.com"
export ICPSR_PASS="your_password"
export ICPSR_TOKEN="your_token"

Project-specific setup

Usually, the config File config.yml will have openicpsr: PROJECT_ID already set. If not, this can be edited and committed to the repository. The script will read that config file to determine the PROJECT_ID.

Examples

# Default usage, reads openICPSR deposit number from config.yml
python3 tools/download_openicpsr-private.py 

# Overriding the default PROJECT_ID from config.yml, or empty config.yml
python3 tools/download_openicpsr-private.py 123456

# Specifying download path
python3 tools/download_openicpsr-private.py 123456 ./downloads

# Interactive login (will prompt for password)
python3 tools/download_openicpsr-private.py 123456 ./downloads your.email@domain.com

Authentication Methods

The script supports multiple authentication methods in order of preference:

  1. Interactive Authentication: Command line login + password prompt

  2. Environment Variables: ICPSR_EMAIL and ICPSR_PASS

Environment Variables

ICPSR_TOKEN

openICPSR sits behind Cloudflare, which may block automated requests (for example, from cloud-hosted pipeline runners) before they reach the login page. ICPSR_TOKEN carries a token, agreed with openICPSR, that lets the script’s requests bypass that check.

Config File Format

openicpsr: 123456  # Your project ID

Requirements

This tool is essential for research workflows that require access to unpublished or private openICPSR deposits during the replication process.