
harvard-art-museum-etl-pipeline
Build ETL pipelines and analytics dashboards using the Harvard Art Museums API with Python, SQL, and Streamlit
- Installs
- 749
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/reason-machines/data-skills --skill harvard-art-museum-etl-pipeline- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads harvard-art-museum-etl-pipeline automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Harvard Art Museum ETL Pipeline
Skill by ara.so — Data Skills collection.
This skill enables you to build end-to-end data engineering and analytics applications using the Harvard Art Museums API. The project demonstrates real-world ETL pipelines, SQL database design, analytical queries, and interactive Streamlit dashboards for museum artifact data.
What This Project Does
The Harvard Artifacts Collection app provides a complete data engineering workflow:
- Extract: Fetch artifact data from Harvard Art Museums API with pagination and rate limiting
- Transform: Convert nested JSON into normalized relational tables (metadata, media, colors)
- Load: Batch insert data into MySQL/TiDB Cloud with proper foreign key relationships
- Analyze: Execute 20+ predefined SQL queries for insights
- Visualize: Display results in interactive Plotly charts via Streamlit
The architecture follows: API → ETL → SQL → Analytics → Visualization
Installation
# Clone the repository
git clone https://github.com/Manali0711/Harvard-Artifacts-Collection-Data-Engineering-Analytics-App.git
cd Harvard-Artifacts-Collection-Data-Engineering-Analytics-App
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
export HARVARD_API_KEY="your_api_key_here"
export DB_HOST="your_database_host"
export DB_USER="your_database_user"
export DB_PASSWORD="your_database_password"
export DB_NAME="harvard_artifacts"
Configuration
API Key Setup
Obtain your Harvard Art Museums API key from: https://www.harvardartmuseums.org/collections/api
Store it securely:
import os
API_KEY = os.getenv('HARVARD_API_KEY')
BASE_URL = "https://api.harvardartmuseums.org/object"
Database Configuration
Configure your MySQL/TiDB connection:
import mysql.connector
import os
db_config = {
'host': os.getenv('DB_HOST'),
'user': os.getenv('DB_USER'),
'password': os.getenv('DB_PASSWORD'),
'database': os.getenv('DB_NAME')
}
conn = mysql.connector.connect(**db_config)
Database Schema
The project uses three normalized tables:
-- Artifact Metadata
CREATE TABLE artifactmetadata (
id INT PRIMARY KEY,
title VARCHAR(500),
culture VARCHAR(200),
period VARCHAR(200),
century VARCHAR(100),
classification VARCHAR(200),
department VARCHAR(200),
division VARCHAR(200),
dated VARCHAR(200),
url TEXT,
primaryimageurl TEXT
);
-- Artifact Media
CREATE TABLE artifactmedia (
media_id INT AUTO_INCREMENT PRIMARY KEY,
artifact_id INT,
media_type VARCHAR(100),
baseimageurl TEXT,
renditionnumber VARCHAR(50),
FOREIGN KEY (artifact_id) REFERENCES artifactmetadata(id)
);
-- Artifact Colors
CREATE TABLE artifactcolors (
color_id INT AUTO_INCREMENT PRIMARY KEY,
artifact_id INT,
color VARCHAR(50),
spectrum VARCHAR(50),
hue VARCHAR(50),
percent FLOAT,
FOREIGN KEY (artifact_id) REFERENCES artifactmetadata(id)
);
Running the Application
# Start the Streamlit app
streamlit run app.py
# The app will be available at http://localhost:8501
ETL Pipeline Implementation
Extract: Fetch Data from API
import requests
import os
def fetch_artifacts(page=1, size=100):
"""Fetch artifacts from Harvard Art Museums API with pagination"""
api_key = os.getenv('HARVARD_API_KEY')
url = "https://api.harvardartmuseums.org/object"
params = {
'apikey': api_key,
'page': page,
'size': size,
'hasimage': 1 # Only artifacts with images
}
response = requests.get(url, params=params)
response.raise_for_status()
data = response.json()
return data['records'], data['info']
# Fetch multiple pages
def extract_all_artifacts(max_pages=10):
all_artifacts = []
for page in range(1, max_pages + 1):
records, info = fetch_artifacts(page=page)
all_artifacts.extend(records)
# Check if more pages exist
if page >= info['pages']:
break
return all_artifacts
Transform: Normalize JSON Data
import pandas as pd
def transform_artifacts(artifacts):
"""Transform raw API data into normalized dataframes"""
# Metadata table
metadata_records = []
media_records = []
color_records = []
for artifact in artifacts:
# Extract metadata
metadata = {
'id': artifact.get('id'),
'title': artifact.get('title', '')[:500],
'culture': artifact.get('culture', '')[:200],
'period': artifact.get('period', '')[:200],
'century': artifact.get('century', '')[:100],
'classification': artifact.get('classification', '')[:200],
'department': artifact.get('department', '')[:200],
'division': artifact.get('division', '')[:200],
'dated': artifact.get('dated', '')[:200],
'url': artifact.get('url'),
'primaryimageurl': artifact.get('primaryimageurl')
}
metadata_records.append(metadata)
# Extract media
if 'images' in artifact and artifact['images']:
for img in artifact['images']:
media = {
'artifact_id': artifact.get('id'),
'media_type': 'image',
'baseimageurl': img.get('baseimageurl'),
'renditionnumber': img.get('renditionnumber')
}
media_records.append(media)
# Extract colors
if 'colors' in artifact and artifact['colors']:
for color in artifact['colors']:
color_record = {
'artifact_id': artifact.get('id'),
'color': color.get('color'),
'spectrum': color.get('spectrum'),
'hue': color.get('hue'),
'percent': color.get('percent')
}
color_records.append(color_record)
return (
pd.DataFrame(metadata_records),
pd.DataFrame(media_records),
pd.DataFrame(color_records)
)
Load: Insert into Database
from mysql.connector import Error
def load_to_database(metadata_df, media_df, colors_df, db_config):
"""Batch load data into MySQL database"""
try:
conn = mysql.connector.connect(**db_config)
cursor = conn.cursor()
# Insert metadata (batch)
metadata_query = """
INSERT INTO artifactmetadata
(id, title, culture, period, century, classification,
department, division, dated, url, primaryimageurl)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
title=VALUES(title), culture=VALUES(culture)
"""
cursor.executemany(metadata_query, metadata_df.values.tolist())
# Insert media
if not media_df.empty:
media_query = """
INSERT INTO artifactmedia
(artifact_id, media_type, baseimageurl, renditionnumber)
VALUES (%s, %s, %s, %s)
"""
cursor.executemany(media_query, media_df.values.tolist())
# Insert colors
if not colors_df.empty:
colors_query = """
INSERT INTO artifactcolors
(artifact_id, color, spectrum, hue, percent)
VALUES (%s, %s, %s, %s, %s)
"""
cursor.executemany(colors_query, colors_df.values.tolist())
conn.commit()
print(f"Loaded {len(metadata_df)} artifacts successfully")
except Error as e:
print(f"Database error: {e}")
conn.rollback()
finally:
cursor.close()
conn.close()
Analytics Queries
Sample SQL Queries
ANALYTICS_QUERIES = {
"Artifacts by Department": """
SELECT department, COUNT(*) as count
FROM artifactmetadata
GROUP BY department
ORDER BY count DESC
LIMIT 10
""",
"Artifacts by Century": """
SELECT century, COUNT(*) as count
FROM artifactmetadata
WHERE century IS NOT NULL
GROUP BY century
ORDER BY count DESC
""",
"Most Common Colors": """
SELECT color, COUNT(*) as count, AVG(percent) as avg_percent
FROM artifactcolors
GROUP BY color
ORDER BY count DESC
LIMIT 15
""",
"Media Availability": """
SELECT
COUNT(DISTINCT m.artifact_id) as artifacts_with_media,
COUNT(*) as total_media_files
FROM artifactmedia m
""",
"Artifacts by Culture and Century": """
SELECT culture, century, COUNT(*) as count
FROM artifactmetadata
WHERE culture IS NOT NULL AND century IS NOT NULL
GROUP BY culture, century
HAVING count > 5
ORDER BY count DESC
LIMIT 20
"""
}
def execute_query(query, db_config):
"""Execute analytical query and return results as DataFrame"""
conn = mysql.connector.connect(**db_config)
df = pd.read_sql(query, conn)
conn.close()
return df
Streamlit Dashboard Implementation
import streamlit as st
import plotly.express as px
def main():
st.set_page_config(page_title="Harvard Artifacts Analytics", layout="wide")
st.title("🏛️ Harvard Art Museums Analytics Dashboard")
# Sidebar for query selection
query_name = st.sidebar.selectbox(
"Select Analysis",
list(ANALYTICS_QUERIES.keys())
)
# Execute query
if st.button("Run Analysis"):
with st.spinner("Executing query..."):
query = ANALYTICS_QUERIES[query_name]
results_df = execute_query(query, db_config)
# Display results
st.subheader(f"Results: {query_name}")
st.dataframe(results_df)
# Auto-generate visualization
if len(results_df.columns) >= 2:
fig = px.bar(
results_df,
x=results_df.columns[0],
y=results_df.columns[1],
title=query_name
)
st.plotly_chart(fig, use_container_width=True)
if __name__ == "__main__":
main()
Common Patterns
Complete ETL Workflow
def run_etl_pipeline(max_pages=5):
"""Complete ETL pipeline execution"""
# Extract
st.info("Extracting data from Harvard Art Museums API...")
artifacts = extract_all_artifacts(max_pages=max_pages)
# Transform
st.info(f"Transforming {len(artifacts)} artifacts...")
metadata_df, media_df, colors_df = transform_artifacts(artifacts)
# Load
st.info("Loading data to database...")
load_to_database(metadata_df, media_df, colors_df, db_config)
st.success(f"ETL complete! Processed {len(artifacts)} artifacts")
return {
'artifacts': len(artifacts),
'media_files': len(media_df),
'color_records': len(colors_df)
}
Rate Limiting for API Calls
import time
def fetch_with_rate_limit(page, size=100, delay=0.5):
"""Fetch data with rate limiting to avoid API throttling"""
records, info = fetch_artifacts(page=page, size=size)
time.sleep(delay) # Wait between requests
return records, info
Troubleshooting
API Connection Issues
# Handle connection errors gracefully
try:
response = requests.get(url, params=params, timeout=10)
response.raise_for_status()
except requests.exceptions.Timeout:
st.error("API request timed out. Please try again.")
except requests.exceptions.RequestException as e:
st.error(f"API error: {e}")
Database Connection Failures
# Test database connection
def test_db_connection(db_config):
try:
conn = mysql.connector.connect(**db_config)
if conn.is_connected():
st.success("Database connected successfully")
conn.close()
return True
except Error as e:
st.error(f"Database connection failed: {e}")
return False
Missing Data Handling
# Handle missing fields in API response
def safe_get(dictionary, key, default='', max_length=None):
"""Safely extract value from dictionary with defaults"""
value = dictionary.get(key, default)
if max_length and value:
value = str(value)[:max_length]
return value
Advanced Usage
Incremental Data Loading
def get_latest_artifact_id(db_config):
"""Get the latest artifact ID from database"""
conn = mysql.connector.connect(**db_config)
cursor = conn.cursor()
cursor.execute("SELECT MAX(id) FROM artifactmetadata")
max_id = cursor.fetchone()[0] or 0
conn.close()
return max_id
def incremental_etl(db_config):
"""Load only new artifacts since last run"""
latest_id = get_latest_artifact_id(db_config)
# Fetch artifacts with ID > latest_id
params = {
'apikey': os.getenv('HARVARD_API_KEY'),
'q': f'id:>{latest_id}',
'size': 100
}
# Continue with ETL...
This skill provides everything needed to build production-ready ETL pipelines for museum data using modern data engineering practices.
FAQ
What does the harvard-art-museum-etl-pipeline skill do?
Build ETL pipelines and analytics dashboards using the Harvard Art Museums API with Python, SQL, and Streamlit
How do I install harvard-art-museum-etl-pipeline?
Run npx skills add https://github.com/reason-machines/data-skills --skill harvard-art-museum-etl-pipeline in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/harvard-art-museum-etl-pipeline/ (personal) or .claude/skills/harvard-art-museum-etl-pipeline/ (project).
Which AI agents can use harvard-art-museum-etl-pipeline?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is harvard-art-museum-etl-pipeline safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains harvard-art-museum-etl-pipeline?
It is published by reason-machines in reason-machines/data-skills. It has 749 recorded installs.
More from reason-machines/data-skills
apache-airflow-orchestration
reason-machines/data-skills
Expert knowledge of Apache Airflow for building, scheduling, and monitoring data pipelines and workflows
datatalks-data-engineering-zoomcamp
reason-machines/data-skills
Free 9-week data engineering course covering Docker, Terraform, Kestra, BigQuery, dbt, Spark, and Kafka with hands-on projects
llm-public-opinion-analytics-assistant
reason-machines/data-skills
Multi-platform hot search crawler and LLM-powered public opinion analysis system with clustering, sentiment analysis, and multi-channel push notifications
roblox-mm2-analytics-toolkit
reason-machines/data-skills
Analytics and inventory management toolkit for Roblox Murder Mystery 2 gameplay optimization
mm2-analytics-roblox-tracker
reason-machines/data-skills
Analyze Murder Mystery 2 gameplay data, track inventory, and optimize strategy using this Roblox analytics toolkit
mm2-roblox-analytics-toolkit
reason-machines/data-skills
Murder Mystery 2 gameplay analytics, inventory tracking, and strategy optimization toolkit for Roblox
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.