Exporting Compliance Reports for Legal Review
This guide shows how to export structured regulation data as CSV files that your legal team can review in Excel, Google Sheets, or their compliance management system. CSV export is available on Professional and Enterprise tiers.
Why Export to CSV?
- Legal teams often work in spreadsheets, not API dashboards
- CSV exports provide a point-in-time snapshot for audit trails
- Easy to attach to compliance reports, board presentations, and regulatory filings
- Can be imported into compliance management tools
Quick Export: Single State
curl -X GET "https://api.hempdataapi.com/v1/regulations?state=CO&format=csv&include_sources=true" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o colorado-regulations.csv
This downloads a CSV file with all Colorado hemp regulations.
Export: All States for a Substance
curl -X GET "https://api.hempdataapi.com/v1/regulations?substance=delta-9-thc&format=csv&per_page=100&include_sources=true" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o delta9-thc-all-states.csv
Export: Multi-State Comparison
curl -X GET "https://api.hempdataapi.com/v1/regulations/compare?states=CO,CA,TX,FL,NY,WA,OR,IL,MA,NV&substance=delta-9-thc&product_type=edibles&format=csv" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o delta9-edibles-comparison.csv
Export: Change History
curl -X GET "https://api.hempdataapi.com/v1/regulations/changelog?since=2026-01-01T00:00:00Z&format=csv" \
-H "Authorization: Bearer YOUR_API_KEY" \
-o regulation-changes-2026.csv
CSV Column Reference
Regulations Export
| Column | Description |
|---|---|
id | Regulation UUID |
state | Two-letter state code |
state_name | Full state name |
substance | Substance identifier |
product_type | Product type |
legal_status | Legal status |
summary | Plain-English summary |
thc_limit | THC limit details |
age_requirement | Minimum age (blank if none) |
license_required | TRUE/FALSE |
testing_required | TRUE/FALSE |
labeling_requirements | Labeling rules |
packaging_requirements | Packaging rules |
sales_channels | Allowed channels (semicolon-separated) |
effective_date | When the regulation took effect |
confidence | Confidence score (0.0 to 1.0) |
last_verified | Last verification timestamp |
source_titles | Source names (semicolon-separated) |
source_urls | Source URLs (semicolon-separated) |
Changelog Export
| Column | Description |
|---|---|
change_id | Change event ID |
regulation_id | Affected regulation UUID |
state | State code |
substance | Substance |
product_type | Product type |
event_type | Type of change |
before_status | Previous legal status |
after_status | New legal status |
diff_summary | Machine-readable diff |
plain_english_summary | Human-readable explanation |
changed_at | When the change occurred |
detected_at | When HempData detected it |
Automated Weekly Reports
Set up a cron job or scheduled task to generate weekly compliance snapshots:
Bash Script
#!/bin/bash
# weekly-compliance-export.sh
# Run via cron: 0 8 * * 1 /path/to/weekly-compliance-export.sh
DATE=$(date +%Y-%m-%d)
API_KEY="YOUR_API_KEY"
BASE="https://api.hempdataapi.com"
OUT_DIR="/path/to/compliance-reports"
mkdir -p "$OUT_DIR"
# Full regulation snapshot
curl -s -X GET "$BASE/v1/regulations?format=csv&per_page=100&include_sources=true" \
-H "Authorization: Bearer $API_KEY" \
-o "$OUT_DIR/all-regulations-$DATE.csv"
# Changes in the last 7 days
SINCE=$(date -v-7d +%Y-%m-%dT00:00:00Z 2>/dev/null || date -d '7 days ago' +%Y-%m-%dT00:00:00Z)
curl -s -X GET "$BASE/v1/regulations/changelog?since=$SINCE&format=csv" \
-H "Authorization: Bearer $API_KEY" \
-o "$OUT_DIR/changes-last-7-days-$DATE.csv"
echo "Reports exported to $OUT_DIR for $DATE"
Node.js Script
const fs = require('fs');
const path = require('path');
const { HempDataClient } = require('@hempdataapi/sdk');
const client = new HempDataClient({ apiKey: process.env.HEMPDATA_API_KEY });
async function generateWeeklyReport() {
const date = new Date().toISOString().split('T')[0];
const outDir = path.join(__dirname, 'compliance-reports');
fs.mkdirSync(outDir, { recursive: true });
// Export all regulations as CSV
const regulations = await client.regulations.list({
format: 'csv',
per_page: 100,
include_sources: true,
});
fs.writeFileSync(path.join(outDir, `all-regulations-${date}.csv`), regulations);
// Export changes from the last 7 days
const since = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
const changes = await client.regulations.changelog({
since,
format: 'csv',
});
fs.writeFileSync(path.join(outDir, `changes-${date}.csv`), changes);
console.log(`Reports saved to ${outDir}`);
}
generateWeeklyReport();
Python Script
import os
import requests
from datetime import datetime, timedelta
API_KEY = os.environ["HEMPDATA_API_KEY"]
BASE_URL = "https://api.hempdataapi.com"
OUT_DIR = "compliance-reports"
DATE = datetime.now().strftime("%Y-%m-%d")
os.makedirs(OUT_DIR, exist_ok=True)
headers = {"Authorization": f"Bearer {API_KEY}"}
# Full regulation snapshot
resp = requests.get(
f"{BASE_URL}/v1/regulations",
headers=headers,
params={"format": "csv", "per_page": 100, "include_sources": "true"},
)
with open(f"{OUT_DIR}/all-regulations-{DATE}.csv", "w") as f:
f.write(resp.text)
# Changes in the last 7 days
since = (datetime.now() - timedelta(days=7)).strftime("%Y-%m-%dT00:00:00Z")
resp = requests.get(
f"{BASE_URL}/v1/regulations/changelog",
headers=headers,
params={"since": since, "format": "csv"},
)
with open(f"{OUT_DIR}/changes-{DATE}.csv", "w") as f:
f.write(resp.text)
print(f"Reports saved to {OUT_DIR}/")
Sending Reports via Email
Combine the export script with email delivery for fully automated compliance reporting:
const nodemailer = require('nodemailer');
const fs = require('fs');
async function emailReport(csvPath, recipients) {
const transporter = nodemailer.createTransport({
host: 'smtp.yourcompany.com',
port: 587,
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS,
},
});
await transporter.sendMail({
from: 'compliance@yourcompany.com',
to: recipients.join(', '),
subject: `Weekly Hemp Compliance Report — ${new Date().toISOString().split('T')[0]}`,
text: 'Attached is the weekly hemp regulation compliance snapshot and change log.',
attachments: [
{ filename: 'regulations.csv', path: csvPath },
],
});
}
Tips for Legal Teams
- Focus on changes — The changelog export highlights what changed and when, which is usually what legal teams care about most.
- Filter by confidence — Add
&min_confidence=0.8to only export high-confidence data. Flag lower-confidence entries for manual review. - Include sources — Always use
include_sources=trueso legal can verify against primary sources. - Archive snapshots — Keep dated copies for audit trails. Regulation data changes over time, and having historical snapshots is valuable for demonstrating due diligence.
- Use the comparison export — The multi-state comparison CSV is ideal for presenting side-by-side regulatory differences to leadership.