
harvard-art-museums-data-engineering
Build end-to-end data pipelines with Harvard Art Museums API, ETL workflows, SQL analytics, and Streamlit dashboards
- Installs
- 843
- 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-museums-data-engineering- 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-museums-data-engineering 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 Museums Data Engineering & Analytics
Skill by ara.so — Data Skills collection.
This skill enables you to build production-ready data engineering pipelines using the Harvard Art Museums API. The project demonstrates real-world ETL patterns, relational database design, SQL analytics, and interactive visualization with Streamlit.
What It Does
- API Integration: Fetches artifact data from Harvard Art Museums API with pagination and rate limiting
- ETL Pipeline: Transforms nested JSON into normalized relational tables
- Database Design: Creates properly structured MySQL/TiDB tables with foreign keys
- SQL Analytics: Executes 20+ analytical queries for insights
- Visualization: Builds interactive Streamlit dashboards with Plotly charts
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
# Required packages
pip install streamlit pandas requests mysql-connector-python plotly python-dotenv
Configuration
Environment Variables
Create a .env file in the project root:
# Harvard Art Museums API
HARVARD_API_KEY=your_api_key_here
# Database Configuration
DB_HOST=your_database_host
DB_PORT=3306
DB_USER=your_db_username
DB_PASSWORD=your_db_password
DB_NAME=harvard_artifacts
Get Harvard API Key
- Visit https://www.harvardartmuseums.org/collections/api
- Request an API key (free)
- Add to your
.envfile
Database Setup
import mysql.connector
from dotenv import load_dotenv
import os
load_dotenv()
# Connect to database
conn = mysql.connector.connect(
host=os.getenv('DB_HOST'),
port=int(os.getenv('DB_PORT', 3306)),
user=os.getenv('DB_USER'),
password=os.getenv('DB_PASSWORD'),
database=os.getenv('DB_NAME')
)
Project Structure
├── app.py # Main Streamlit application
├── etl_pipeline.py # ETL logic for data extraction/transformation
├── database.py # Database connection and operations
├── queries.py # SQL analytics queries
├── requirements.txt # Python dependencies
└── .env # Environment configuration
Core Components
1. API Data Extraction
import requests
import pandas as pd
from typing import List, Dict
import os
def fetch_artifacts(api_key: str, size: int = 100, page: int = 1) -> Dict:
"""Fetch artifacts from Harvard Art Museums API"""
url = "https://api.harvardartmuseums.org/object"
params = {
'apikey': api_key,
'size': size,
'page': page,
'hasimage': 1 # Only artifacts with images
}
response = requests.get(url, params=params)
response.raise_for_status()
return response.json()
def collect_artifacts(api_key: str, total_records: int = 500) -> List[Dict]:
"""Collect multiple pages of artifact data"""
artifacts = []
page = 1
page_size = 100
while len(artifacts) < total_records:
data = fetch_artifacts(api_key, size=page_size, page=page)
records = data.get('records', [])
if not records:
break
artifacts.extend(records)
page += 1
# Respect rate limits
import time
time.sleep(0.5)
return artifacts[:total_records]
2. Data Transformation
import pandas as pd
def transform_artifact_metadata(artifacts: List[Dict]) -> pd.DataFrame:
"""Transform raw API data into metadata DataFrame"""
metadata = []
for artifact in artifacts:
metadata.append({
'objectid': artifact.get('objectid'),
'title': artifact.get('title'),
'culture': artifact.get('culture'),
'period': artifact.get('period'),
'century': artifact.get('century'),
'classification': artifact.get('classification'),
'medium': artifact.get('medium'),
'dated': artifact.get('dated'),
'department': artifact.get('department'),
'division': artifact.get('division'),
'creditline': artifact.get('creditline'),
'accessionyear': artifact.get('accessionyear')
})
return pd.DataFrame(metadata)
def transform_artifact_media(artifacts: List[Dict]) -> pd.DataFrame:
"""Extract media/image information"""
media_records = []
for artifact in artifacts:
objectid = artifact.get('objectid')
images = artifact.get('images', [])
for img in images:
media_records.append({
'objectid': objectid,
'imageid': img.get('imageid'),
'baseimageurl': img.get('baseimageurl'),
'width': img.get('width'),
'height': img.get('height'),
'format': img.get('format')
})
return pd.DataFrame(media_records)
def transform_artifact_colors(artifacts: List[Dict]) -> pd.DataFrame:
"""Extract color information"""
color_records = []
for artifact in artifacts:
objectid = artifact.get('objectid')
colors = artifact.get('colors', [])
for color in colors:
color_records.append({
'objectid': objectid,
'color': color.get('color'),
'spectrum': color.get('spectrum'),
'hue': color.get('hue'),
'percent': color.get('percent')
})
return pd.DataFrame(color_records)
3. Database Schema Creation
def create_database_schema(conn):
"""Create normalized database tables"""
cursor = conn.cursor()
# Artifact Metadata Table
cursor.execute("""
CREATE TABLE IF NOT EXISTS artifactmetadata (
objectid INT PRIMARY KEY,
title TEXT,
culture VARCHAR(255),
period VARCHAR(255),
century VARCHAR(100),
classification VARCHAR(255),
medium TEXT,
dated VARCHAR(255),
department VARCHAR(255),
division VARCHAR(255),
creditline TEXT,
accessionyear INT
)
""")
# Artifact Media Table
cursor.execute("""
CREATE TABLE IF NOT EXISTS artifactmedia (
id INT AUTO_INCREMENT PRIMARY KEY,
objectid INT,
imageid INT,
baseimageurl TEXT,
width INT,
height INT,
format VARCHAR(50),
FOREIGN KEY (objectid) REFERENCES artifactmetadata(objectid)
)
""")
# Artifact Colors Table
cursor.execute("""
CREATE TABLE IF NOT EXISTS artifactcolors (
id INT AUTO_INCREMENT PRIMARY KEY,
objectid INT,
color VARCHAR(50),
spectrum VARCHAR(50),
hue VARCHAR(50),
percent FLOAT,
FOREIGN KEY (objectid) REFERENCES artifactmetadata(objectid)
)
""")
conn.commit()
cursor.close()
4. Batch Data Loading
def load_dataframe_to_table(df: pd.DataFrame, table_name: str, conn):
"""Batch insert DataFrame into SQL table"""
if df.empty:
return
cursor = conn.cursor()
# Prepare INSERT statement
columns = ', '.join(df.columns)
placeholders = ', '.join(['%s'] * len(df.columns))
query = f"INSERT IGNORE INTO {table_name} ({columns}) VALUES ({placeholders})"
# Convert DataFrame to list of tuples
data = [tuple(row) for row in df.values]
# Execute batch insert
cursor.executemany(query, data)
conn.commit()
cursor.close()
print(f"Loaded {len(df)} records into {table_name}")
5. Analytics Queries
# Sample analytical queries
ANALYTICS_QUERIES = {
"Artifacts by Century": """
SELECT century, COUNT(*) as artifact_count
FROM artifactmetadata
WHERE century IS NOT NULL
GROUP BY century
ORDER BY artifact_count DESC
LIMIT 10
""",
"Top Cultures": """
SELECT culture, COUNT(*) as count
FROM artifactmetadata
WHERE culture IS NOT NULL
GROUP BY culture
ORDER BY count DESC
LIMIT 15
""",
"Department Distribution": """
SELECT department, COUNT(*) as total_artifacts
FROM artifactmetadata
WHERE department IS NOT NULL
GROUP BY department
ORDER BY total_artifacts DESC
""",
"Color Spectrum Analysis": """
SELECT spectrum, COUNT(*) as occurrence,
AVG(percent) as avg_percent
FROM artifactcolors
WHERE spectrum IS NOT NULL
GROUP BY spectrum
ORDER BY occurrence DESC
""",
"Media Format Distribution": """
SELECT format, COUNT(*) as image_count,
AVG(width) as avg_width, AVG(height) as avg_height
FROM artifactmedia
WHERE format IS NOT NULL
GROUP BY format
ORDER BY image_count DESC
""",
"Artifacts with Multiple Images": """
SELECT a.title, a.culture, COUNT(m.imageid) as image_count
FROM artifactmetadata a
JOIN artifactmedia m ON a.objectid = m.objectid
GROUP BY a.objectid, a.title, a.culture
HAVING image_count > 3
ORDER BY image_count DESC
LIMIT 20
"""
}
def execute_query(conn, query: str) -> pd.DataFrame:
"""Execute SQL query and return results as DataFrame"""
return pd.read_sql(query, conn)
6. Streamlit Dashboard
import streamlit as st
import plotly.express as px
from dotenv import load_dotenv
load_dotenv()
st.set_page_config(page_title="Harvard Art Museums Analytics", layout="wide")
st.title("🎨 Harvard Art Museums - Data Analytics Dashboard")
# Database connection
@st.cache_resource
def get_database_connection():
return mysql.connector.connect(
host=os.getenv('DB_HOST'),
user=os.getenv('DB_USER'),
password=os.getenv('DB_PASSWORD'),
database=os.getenv('DB_NAME')
)
conn = get_database_connection()
# Sidebar for query selection
st.sidebar.header("Analytics Queries")
query_name = st.sidebar.selectbox(
"Select Analysis",
list(ANALYTICS_QUERIES.keys())
)
# Execute selected query
if st.sidebar.button("Run Query"):
with st.spinner("Executing query..."):
query = ANALYTICS_QUERIES[query_name]
results = execute_query(conn, query)
st.subheader(f"Results: {query_name}")
st.dataframe(results)
# Auto-generate visualization
if len(results.columns) >= 2:
fig = px.bar(
results,
x=results.columns[0],
y=results.columns[1],
title=query_name
)
st.plotly_chart(fig, use_container_width=True)
# ETL Pipeline Section
st.sidebar.header("ETL Pipeline")
if st.sidebar.button("Run ETL"):
api_key = os.getenv('HARVARD_API_KEY')
with st.spinner("Fetching artifacts..."):
artifacts = collect_artifacts(api_key, total_records=100)
st.success(f"Fetched {len(artifacts)} artifacts")
with st.spinner("Transforming data..."):
df_metadata = transform_artifact_metadata(artifacts)
df_media = transform_artifact_media(artifacts)
df_colors = transform_artifact_colors(artifacts)
st.success("Data transformation complete")
with st.spinner("Loading to database..."):
load_dataframe_to_table(df_metadata, 'artifactmetadata', conn)
load_dataframe_to_table(df_media, 'artifactmedia', conn)
load_dataframe_to_table(df_colors, 'artifactcolors', conn)
st.success("Data loaded successfully!")
Running the Application
# Start the Streamlit dashboard
streamlit run app.py
# Access at http://localhost:8501
Common Patterns
Pattern 1: Incremental Data Collection
def get_latest_objectid(conn) -> int:
"""Get the highest objectid already in database"""
cursor = conn.cursor()
cursor.execute("SELECT MAX(objectid) FROM artifactmetadata")
result = cursor.fetchone()
cursor.close()
return result[0] or 0
def incremental_etl(api_key: str, conn):
"""Only fetch new artifacts"""
latest_id = get_latest_objectid(conn)
# Fetch with filter
url = "https://api.harvardartmuseums.org/object"
params = {
'apikey': api_key,
'size': 100,
'q': f'objectid:>{latest_id}'
}
response = requests.get(url, params=params)
new_artifacts = response.json().get('records', [])
# Transform and load only new records
if new_artifacts:
df = transform_artifact_metadata(new_artifacts)
load_dataframe_to_table(df, 'artifactmetadata', conn)
Pattern 2: Error Handling for API Calls
import time
from requests.exceptions import RequestException
def robust_fetch_artifacts(api_key: str, max_retries: int = 3):
"""Fetch with retry logic"""
for attempt in range(max_retries):
try:
response = requests.get(
"https://api.harvardartmuseums.org/object",
params={'apikey': api_key, 'size': 100},
timeout=10
)
response.raise_for_status()
return response.json()
except RequestException as e:
if attempt < max_retries - 1:
wait_time = 2 ** attempt # Exponential backoff
time.sleep(wait_time)
else:
raise Exception(f"Failed after {max_retries} attempts: {e}")
Pattern 3: Data Quality Validation
def validate_artifacts(df: pd.DataFrame) -> pd.DataFrame:
"""Clean and validate artifact data"""
# Remove duplicates
df = df.drop_duplicates(subset=['objectid'])
# Fill missing values
df['culture'] = df['culture'].fillna('Unknown')
df['century'] = df['century'].fillna('Undated')
# Data type conversions
df['accessionyear'] = pd.to_numeric(df['accessionyear'], errors='coerce')
# Filter invalid records
df = df[df['objectid'].notna()]
return df
Troubleshooting
Issue: API Rate Limiting
# Add delays between requests
import time
for page in range(1, 10):
data = fetch_artifacts(api_key, page=page)
time.sleep(1) # 1 second delay
Issue: Database Connection Timeout
# Use connection pooling
from mysql.connector import pooling
db_pool = pooling.MySQLConnectionPool(
pool_name="harvard_pool",
pool_size=5,
host=os.getenv('DB_HOST'),
user=os.getenv('DB_USER'),
password=os.getenv('DB_PASSWORD'),
database=os.getenv('DB_NAME')
)
conn = db_pool.get_connection()
Issue: Large Dataset Memory Errors
# Process in chunks
def chunked_etl(api_key: str, conn, chunk_size: int = 100):
"""Process data in manageable chunks"""
page = 1
while True:
artifacts = fetch_artifacts(api_key, size=chunk_size, page=page)
if not artifacts:
break
# Transform and load chunk
df = transform_artifact_metadata(artifacts)
load_dataframe_to_table(df, 'artifactmetadata', conn)
page += 1
Issue: NULL Values in Foreign Keys
# Ensure parent records exist before inserting children
def safe_load_media(df_media: pd.DataFrame, conn):
"""Only load media for existing artifacts"""
cursor = conn.cursor()
cursor.execute("SELECT objectid FROM artifactmetadata")
valid_ids = {row[0] for row in cursor.fetchall()}
cursor.close()
# Filter media records
df_filtered = df_media[df_media['objectid'].isin(valid_ids)]
load_dataframe_to_table(df_filtered, 'artifactmedia', conn)
Key Commands
# Run full ETL pipeline
python -c "from etl_pipeline import run_full_etl; run_full_etl()"
# Launch dashboard
streamlit run app.py
# Run specific query
python -c "from queries import execute_query; execute_query('SELECT * FROM artifactmetadata LIMIT 10')"
This skill provides everything needed to build production-grade data pipelines for cultural heritage data using modern Python data engineering tools.
FAQ
What does the harvard-art-museums-data-engineering skill do?
Build end-to-end data pipelines with Harvard Art Museums API, ETL workflows, SQL analytics, and Streamlit dashboards
How do I install harvard-art-museums-data-engineering?
Run npx skills add https://github.com/reason-machines/data-skills --skill harvard-art-museums-data-engineering 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-museums-data-engineering/ (personal) or .claude/skills/harvard-art-museums-data-engineering/ (project).
Which AI agents can use harvard-art-museums-data-engineering?
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-museums-data-engineering 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-museums-data-engineering?
It is published by reason-machines in reason-machines/data-skills. It has 843 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 media & creative skills
hyperframes
heygen-com/hyperframes
Read first to make, edit, animate or render any video with HyperFrames (HTML rendered to video), including launch films, explainers, music videos, charts, maps, vertical clips, title cards, captions and overlays. Holds the render contract, the work loop and what each kind of video needs.
media-use
heygen-com/hyperframes
Get or make any media for a HyperFrames video - music, sound effects, images, icons, logos, voiceover, avatar and generated video, transcripts, cutouts, colour grades and looks - with HeyGen or free local tools, and mix placed audio. Also for footage that looks dark, flat or dull, or should be stylized or hidden.
hyperframes-registry
heygen-com/hyperframes
About 450 ready-made HyperFrames blocks and components installed as editable source - transitions, overlays, titles, kinetic type, captions, charts, map overlays, 3D, camera moves. Use it before hand-building any named visual (CRT scanlines, glitch, film grain, a chart); also for hyperframes add and catalog.
hyperframes-creative
heygen-com/hyperframes
Non-animation creative direction for HyperFrames videos. Use for design spec (frame.md / design.md) handling, palettes, typography, narration, beat planning, audio-reactive visuals, composition patterns, and brand / style decisions. For atomic motion patterns and scene blueprints, use hyperframes-animation.
ai-video-generation
101-skills/superpowers
Generate AI videos with Google Veo, Seedance 2.0, HappyHorse, Wan, Grok and 40+ models via inference.sh CLI. Models: Veo 3.1, Veo 3, Seedance 2.0, HappyHorse 1.0, Wan 2.5, Grok Imagine Video, OmniHuman, Fabric, HunyuanVideo. Capabilities: text-to-video, image-to-video, reference-to-video, video editing, lipsync, avatar animation, video upscaling, foley sound. Use for: social media videos, marketing content, explainer videos, product demos, AI avatars. Triggers: video generation, ai video, text to video, image to video, veo, animate image, video from image, ai animation, video generator, generate video, t2v, i2v, ai video maker, create video with ai, runway alternative, pika alternative, sora alternative, kling alternative, seedance, happyhorse
ai-image-generation
101-skills/superpowers
Generate AI images with GPT-Image-2, FLUX, Gemini, Grok, Seedream, Reve and 50+ models via inference.sh CLI. Models: GPT-Image-2, FLUX Dev LoRA, FLUX.2 Klein LoRA, Gemini 3 Pro Image, Grok Imagine, Seedream 4.5, Reve, ImagineArt. Capabilities: text-to-image, image-to-image, inpainting, LoRA, image editing, upscaling, text rendering. Use for: AI art, product mockups, concept art, social media graphics, marketing visuals, illustrations. Triggers: flux, image generation, ai image, text to image, stable diffusion, generate image, ai art, midjourney alternative, dall-e alternative, text2img, t2i, image generator, ai picture, create image with ai, generative ai, ai illustration, grok image, gemini image, gpt image, openai image, chatgpt image