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

ColumnDescription
idRegulation UUID
stateTwo-letter state code
state_nameFull state name
substanceSubstance identifier
product_typeProduct type
legal_statusLegal status
summaryPlain-English summary
thc_limitTHC limit details
age_requirementMinimum age (blank if none)
license_requiredTRUE/FALSE
testing_requiredTRUE/FALSE
labeling_requirementsLabeling rules
packaging_requirementsPackaging rules
sales_channelsAllowed channels (semicolon-separated)
effective_dateWhen the regulation took effect
confidenceConfidence score (0.0 to 1.0)
last_verifiedLast verification timestamp
source_titlesSource names (semicolon-separated)
source_urlsSource URLs (semicolon-separated)

Changelog Export

ColumnDescription
change_idChange event ID
regulation_idAffected regulation UUID
stateState code
substanceSubstance
product_typeProduct type
event_typeType of change
before_statusPrevious legal status
after_statusNew legal status
diff_summaryMachine-readable diff
plain_english_summaryHuman-readable explanation
changed_atWhen the change occurred
detected_atWhen 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 },
    ],
  });
}
  1. Focus on changes — The changelog export highlights what changed and when, which is usually what legal teams care about most.
  2. Filter by confidence — Add &min_confidence=0.8 to only export high-confidence data. Flag lower-confidence entries for manual review.
  3. Include sources — Always use include_sources=true so legal can verify against primary sources.
  4. Archive snapshots — Keep dated copies for audit trails. Regulation data changes over time, and having historical snapshots is valuable for demonstrating due diligence.
  5. Use the comparison export — The multi-state comparison CSV is ideal for presenting side-by-side regulatory differences to leadership.