How to Check if a Product is Legal in a State
This guide walks you through using HempData API to determine whether a specific hemp product can be legally sold or shipped to a given state.
Overview
The most common use case for HempData API is answering: "Can I sell [product] in [state]?" This involves a single API call that returns a structured legal status, restrictions, and confidence score.
Step 1: Identify Your Product Parameters
You need three pieces of information:
| Parameter | Example | Description |
|---|---|---|
substance | delta-9-thc | The primary cannabinoid in your product |
product_type | edibles | The product category |
state | TX | The target state (two-letter code) |
Common Substance IDs
| ID | Name |
|---|---|
delta-9-thc | Delta-9 THC |
delta-8-thc | Delta-8 THC |
cbd | CBD (Cannabidiol) |
thca | THCA |
cbg | CBG |
cbn | CBN |
Common Product Type IDs
| ID | Name |
|---|---|
edibles | Gummies, chocolates, baked goods |
topicals | Creams, balms, patches |
smokable | Pre-rolls, flower for smoking |
tinctures | Sublingual drops |
beverages | Infused drinks |
flower | Raw hemp flower |
concentrates | Wax, shatter, distillate |
pet-products | Animal treats and tinctures |
Step 2: Make the API Call
curl -X GET "https://api.hempdataapi.com/v1/regulations?state=TX&substance=delta-9-thc&product_type=edibles&include_sources=true" \
-H "Authorization: Bearer YOUR_API_KEY"
Step 3: Interpret the Response
{
"success": true,
"data": [
{
"id": "reg_f1e2d3c4-5678-9012-abcd-ef3456789012",
"state": "TX",
"substance": "delta-9-thc",
"product_type": "edibles",
"legal_status": "prohibited",
"summary": "Delta-9 THC edibles are prohibited in Texas following HB 1842.",
"details": {
"thc_limit": "N/A — prohibited",
"age_requirement": null,
"license_required": false,
"additional_restrictions": "All hemp-derived THC edibles banned effective March 1, 2026."
},
"confidence": 0.88,
"last_verified": "2026-03-18T06:00:00Z"
}
]
}
Decision Logic Based on legal_status
| Status | Action |
|---|---|
legal | Safe to sell. No special conditions. |
legal_with_restrictions | Can sell, but review details for age requirements, limits, and licensing. |
restricted | Significant limitations — review carefully. May require medical license, special permits, etc. |
prohibited | Do not sell or ship to this state. |
unclear | Regulatory status is uncertain. Consult legal counsel before proceeding. |
Confidence Score
The confidence field (0.0 to 1.0) indicates how reliable the data is:
| Score | Interpretation |
|---|---|
| 0.90+ | High confidence — based on current statute with recent verification |
| 0.70 - 0.89 | Moderate confidence — may have pending legislation or recent changes |
| Below 0.70 | Low confidence — consider verifying with legal counsel |
Step 4: Check Multiple States at Once
If you sell nationwide, use the compare endpoint to check several states simultaneously:
curl -X GET "https://api.hempdataapi.com/v1/regulations/compare?states=CO,CA,TX,FL,NY&substance=delta-9-thc&product_type=edibles" \
-H "Authorization: Bearer YOUR_API_KEY"
This returns a side-by-side comparison with a summary.
Full Node.js Example
const axios = require('axios');
const API_KEY = process.env.HEMPDATA_API_KEY;
const BASE_URL = 'https://api.hempdataapi.com';
async function checkLegality(substance, productType, state) {
const response = await axios.get(`${BASE_URL}/v1/regulations`, {
headers: { Authorization: `Bearer ${API_KEY}` },
params: {
state,
substance,
product_type: productType,
include_sources: true,
},
});
const { data } = response.data;
if (data.length === 0) {
return { canSell: false, reason: 'No regulation data found. Treat as unclear.' };
}
const reg = data[0];
switch (reg.legal_status) {
case 'legal':
return { canSell: true, reason: reg.summary, restrictions: [] };
case 'legal_with_restrictions':
return {
canSell: true,
reason: reg.summary,
restrictions: reg.details,
ageRequired: reg.details.age_requirement,
};
case 'restricted':
return { canSell: false, reason: reg.summary, note: 'May be possible with special licensing.' };
case 'prohibited':
return { canSell: false, reason: reg.summary };
case 'unclear':
return { canSell: false, reason: 'Status unclear. Consult legal counsel.' };
default:
return { canSell: false, reason: 'Unknown status.' };
}
}
// Usage
(async () => {
const result = await checkLegality('delta-9-thc', 'edibles', 'CO');
console.log(result);
// { canSell: true, reason: 'Delta-9 THC edibles are legal in Colorado...', restrictions: {...}, ageRequired: 21 }
})();
Full Python Example
import requests
import os
API_KEY = os.environ["HEMPDATA_API_KEY"]
BASE_URL = "https://api.hempdataapi.com"
def check_legality(substance: str, product_type: str, state: str) -> dict:
response = requests.get(
f"{BASE_URL}/v1/regulations",
headers={"Authorization": f"Bearer {API_KEY}"},
params={
"state": state,
"substance": substance,
"product_type": product_type,
"include_sources": "true",
},
)
response.raise_for_status()
data = response.json()["data"]
if not data:
return {"can_sell": False, "reason": "No regulation data found."}
reg = data[0]
status = reg["legal_status"]
if status == "legal":
return {"can_sell": True, "reason": reg["summary"]}
elif status == "legal_with_restrictions":
return {
"can_sell": True,
"reason": reg["summary"],
"restrictions": reg["details"],
}
elif status == "prohibited":
return {"can_sell": False, "reason": reg["summary"]}
else:
return {"can_sell": False, "reason": f"Status: {status}. Consult legal counsel."}
# Usage
result = check_legality("delta-9-thc", "edibles", "CO")
print(result)
Next Steps
- Set up webhook alerts to get notified when regulations change
- Embed the compliance widget on your product pages
- Export compliance reports for your legal team