
harvard-artifacts-data-pipeline
Build end-to-end data engineering pipelines using Harvard Art Museums API with ETL, SQL analytics, and Streamlit visualization
- Installs
- 1.8K
- 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-artifacts-data-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-artifacts-data-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 Artifacts Data Pipeline
Skill by ara.so — Data Skills collection.
What This Project Does
The Harvard Artifacts Collection Data Engineering & Analytics App is an end-to-end data pipeline that demonstrates professional ETL workflows. It fetches artifact data from the Harvard Art Museums API, transforms it into structured relational tables, stores it in MySQL/TiDB Cloud, and provides interactive analytics through a Streamlit dashboard with Plotly visualizations.
Key capabilities:
- API data extraction with pagination and rate limiting
- ETL transformations for nested JSON to relational schema
- SQL database design with proper foreign keys
- 20+ predefined analytical queries
- Interactive visualization dashboards
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"
Required packages:
streamlit
pandas
requests
mysql-connector-python
plotly
python-dotenv
Configuration
API Setup
Get your Harvard Art Museums API key from: https://docs.harvardartmuseums.org/
import os
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv('HARVARD_API_KEY')
BASE_URL = "https://api.harvardartmuseums.org/object"
Database Schema
The project uses three main tables:
-- Artifact metadata table
CREATE TABLE artifactmetadata (
objectid INT PRIMARY KEY,
title VARCHAR(500),
culture VARCHAR(200),
century VARCHAR(100),
division VARCHAR(200),
classification VARCHAR(200),
dated VARCHAR(200),
accessionyear INT,
peoplecount INT,
totalpageviews INT
);
-- Artifact media table
CREATE TABLE artifactmedia (
id INT AUTO_INCREMENT PRIMARY KEY,
objectid INT,
imagecount INT,
videocount INT,
hasimage BOOLEAN,
primaryimageurl TEXT,
FOREIGN KEY (objectid) REFERENCES artifactmetadata(objectid)
);
-- Artifact colors table
CREATE TABLE 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)
);
Key API Patterns
Fetching Artifacts with Pagination
import requests
import pandas as pd
def fetch_artifacts(api_key, num_records=100, page_size=100):
"""
Fetch artifacts from Harvard Art Museums API with pagination
"""
url = f"https://api.harvardartmuseums.org/object"
params = {
'apikey': api_key,
'size': page_size,
'page': 1
}
all_records = []
while len(all_records) < num_records:
response = requests.get(url, params=params)
if response.status_code != 200:
print(f"Error: {response.status_code}")
break
data = response.json()
records = data.get('records', [])
if not records:
break
all_records.extend(records)
params['page'] += 1
# Rate limiting
import time
time.sleep(0.5)
return all_records[:num_records]
ETL Transformation
def transform_artifacts(raw_data):
"""
Transform raw API data into structured DataFrames
"""
metadata_list = []
media_list = []
colors_list = []
for artifact in raw_data:
# Extract metadata
metadata = {
'objectid': artifact.get('objectid'),
'title': artifact.get('title'),
'culture': artifact.get('culture'),
'century': artifact.get('century'),
'division': artifact.get('division'),
'classification': artifact.get('classification'),
'dated': artifact.get('dated'),
'accessionyear': artifact.get('accessionyear'),
'peoplecount': artifact.get('peoplecount', 0),
'totalpageviews': artifact.get('totalpageviews', 0)
}
metadata_list.append(metadata)
# Extract media info
media = {
'objectid': artifact.get('objectid'),
'imagecount': artifact.get('imagecount', 0),
'videocount': artifact.get('videocount', 0),
'hasimage': artifact.get('primaryimageurl') is not None,
'primaryimageurl': artifact.get('primaryimageurl')
}
media_list.append(media)
# Extract colors
colors = artifact.get('colors', [])
for color in colors:
color_data = {
'objectid': artifact.get('objectid'),
'color': color.get('color'),
'spectrum': color.get('spectrum'),
'hue': color.get('hue'),
'percent': color.get('percent')
}
colors_list.append(color_data)
return (
pd.DataFrame(metadata_list),
pd.DataFrame(media_list),
pd.DataFrame(colors_list)
)
Database Operations
Loading Data into MySQL
import mysql.connector
from mysql.connector import Error
def create_database_connection():
"""
Create MySQL database connection
"""
try:
connection = mysql.connector.connect(
host=os.getenv('DB_HOST'),
user=os.getenv('DB_USER'),
password=os.getenv('DB_PASSWORD'),
database=os.getenv('DB_NAME')
)
return connection
except Error as e:
print(f"Error connecting to MySQL: {e}")
return None
def batch_insert_metadata(df_metadata, connection):
"""
Batch insert artifact metadata
"""
cursor = connection.cursor()
insert_query = """
INSERT INTO artifactmetadata
(objectid, title, culture, century, division, classification,
dated, accessionyear, peoplecount, totalpageviews)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
title=VALUES(title), culture=VALUES(culture)
"""
data_tuples = [tuple(row) for row in df_metadata.values]
try:
cursor.executemany(insert_query, data_tuples)
connection.commit()
print(f"Inserted {cursor.rowcount} records into artifactmetadata")
except Error as e:
print(f"Error inserting data: {e}")
connection.rollback()
finally:
cursor.close()
Analytical SQL Queries
Example Queries
ANALYTICAL_QUERIES = {
"Top 10 Cultures by Artifact Count": """
SELECT culture, COUNT(*) as artifact_count
FROM artifactmetadata
WHERE culture IS NOT NULL
GROUP BY culture
ORDER BY artifact_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
""",
"Image Availability Analysis": """
SELECT
hasimage,
COUNT(*) as count,
ROUND(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM artifactmedia), 2) as percentage
FROM artifactmedia
GROUP BY hasimage
""",
"Top Colors Used": """
SELECT color, COUNT(*) as usage_count, AVG(percent) as avg_percentage
FROM artifactcolors
WHERE color IS NOT NULL
GROUP BY color
ORDER BY usage_count DESC
LIMIT 10
""",
"Most Viewed Artifacts": """
SELECT title, culture, totalpageviews
FROM artifactmetadata
WHERE totalpageviews > 0
ORDER BY totalpageviews DESC
LIMIT 10
"""
}
Streamlit Dashboard
Basic App Structure
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 - Data Analytics Dashboard")
# Sidebar configuration
st.sidebar.header("Configuration")
# API Data Collection
if st.sidebar.button("Fetch New Data"):
with st.spinner("Fetching artifacts..."):
raw_data = fetch_artifacts(API_KEY, num_records=500)
df_meta, df_media, df_colors = transform_artifacts(raw_data)
# Load to database
conn = create_database_connection()
if conn:
batch_insert_metadata(df_meta, conn)
# ... insert other tables
st.success("Data loaded successfully!")
# Analytics Section
st.header("📊 SQL Analytics")
query_name = st.selectbox("Select Analysis", list(ANALYTICAL_QUERIES.keys()))
if st.button("Run Query"):
conn = create_database_connection()
if conn:
df_result = pd.read_sql(ANALYTICAL_QUERIES[query_name], conn)
st.subheader("Query Results")
st.dataframe(df_result)
# Auto-generate visualization
if len(df_result.columns) >= 2:
fig = px.bar(
df_result,
x=df_result.columns[0],
y=df_result.columns[1],
title=query_name
)
st.plotly_chart(fig, use_container_width=True)
if __name__ == "__main__":
main()
Running the Application
# Start the Streamlit app
streamlit run app.py
# The app will be available at http://localhost:8501
Common Patterns
Error Handling for API Calls
def safe_api_fetch(url, params, max_retries=3):
"""
Fetch data with retry logic
"""
for attempt in range(max_retries):
try:
response = requests.get(url, params=params, timeout=10)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
if attempt == max_retries - 1:
raise
time.sleep(2 ** attempt) # Exponential backoff
return None
Data Validation
def validate_artifact_data(df):
"""
Validate DataFrame before database insertion
"""
# Remove duplicates
df = df.drop_duplicates(subset=['objectid'])
# Handle null values
df['culture'] = df['culture'].fillna('Unknown')
df['century'] = df['century'].fillna('Unknown')
# Validate data types
df['accessionyear'] = pd.to_numeric(df['accessionyear'], errors='coerce')
return df
Troubleshooting
API Rate Limiting:
# Add delays between requests
import time
time.sleep(0.5) # 500ms delay
# Use session for connection pooling
session = requests.Session()
response = session.get(url, params=params)
Database Connection Issues:
# Test connection
def test_db_connection():
try:
conn = create_database_connection()
if conn and conn.is_connected():
print("Database connection successful")
conn.close()
return True
except Error as e:
print(f"Connection failed: {e}")
return False
Memory Management for Large Datasets:
# Process in chunks
def fetch_in_batches(total_records, batch_size=100):
for start in range(0, total_records, batch_size):
batch = fetch_artifacts(API_KEY, num_records=batch_size)
yield batch
FAQ
What does the harvard-artifacts-data-pipeline skill do?
Build end-to-end data engineering pipelines using Harvard Art Museums API with ETL, SQL analytics, and Streamlit visualization
How do I install harvard-artifacts-data-pipeline?
Run npx skills add https://github.com/reason-machines/data-skills --skill harvard-artifacts-data-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-artifacts-data-pipeline/ (personal) or .claude/skills/harvard-artifacts-data-pipeline/ (project).
Which AI agents can use harvard-artifacts-data-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-artifacts-data-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-artifacts-data-pipeline?
It is published by reason-machines in reason-machines/data-skills. It has 1,821 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.