Skip to main content

Python SDK for the ALETHEIA Safety Database API — chemical safety data for 1,880+ compounds with typed responses

Project description

aletheia-safety

Python SDK for the ALETHEIA Safety Database API — chemical safety data for 1,800+ compounds, 950+ materials, and 520+ consumer products.

Install

pip install aletheia-safety

Quick Start

from aletheia_safety import Aletheia

# Free tier (500 requests/day per IP)
client = Aletheia()

# Or with an API key for higher limits
client = Aletheia(api_key="aletheia_live_…")

Usage

Look up compounds

# By HQ ID
glyphosate = client.compound("hq-c-org-000001")
print(glyphosate["name"])  # "Glyphosate"

# By CAS number
bpa = client.compound_by_cas("80-05-7")

# With safety context
risk = client.compound("hq-c-org-000001", context="human_adult")

# Batch lookup (up to 20)
results = client.batch(["hq-c-org-000001", "hq-c-org-000005"])

Search

# Full-text search across all entity types
results = client.search("sodium")

# Filter by type
compounds = client.search("sodium", type="compound", limit=10)

# Filter by risk level and context
high_risk = client.filter(risk="high", context="food_contact")

# Filter by regulatory agency
epa = client.filter(agency="EPA", year_min=2020)

Compare compounds

# Side-by-side comparison (2-5 compounds)
comparison = client.compare(
    ["hq-c-org-000001", "hq-c-org-000005"],
    context="human_adult"
)

Explore relationships

# Direct relationships
rels = client.relationships("hq-c-org-000001")

# Multi-hop graph traversal
graph = client.graph("hq-c-org-000001", depth=2)
print(f"{len(graph['nodes'])} nodes, {len(graph['edges'])} edges")

Regulatory data

# Classifications for a compound
reg = client.regulatory("hq-c-org-000001")

# All agencies
agencies = client.regulatory_agencies()

# Compounds classified by a specific agency
iarc = client.regulatory_by_agency("IARC")

Exposure sources

# Where a compound is found
sources = client.found_in("hq-c-org-000001")

# All categories
cats = client.found_in_categories()

# Compounds in a category
food = client.found_in_by_category("Food")

Products & Materials

products = client.products(limit=50)
product = client.product("hq-p-hom-000001")

materials = client.materials(limit=50)
material = client.material("hq-m-str-000001")

Fragrance ingredients

fragrances = client.fragrance(limit=50)
classes = client.fragrance_classes()
results = client.fragrance_search("lavender")

Embeddable badge

url = client.badge_url("hq-c-org-000001")
# Use in HTML: <img src="{url}" alt="Safety badge"/>

Key management

status = client.key_status()
print(f"Tier: {status['tier']}, Used: {status['usage']['today']}")

# Rotate a compromised key (client auto-updates)
result = client.key_rotate()
print(f"New key: {result['key']}")

# Usage history
usage = client.key_usage(days=14)
for day in usage["usage"]:
    print(f"{day['date']}: {day['requests']} requests")

Watchlist (Developer+)

# Add compounds to your watchlist
client.watchlist_add(["hq-c-org-000001", "hq-c-org-000033"])

# List watched compounds with enrichment
watched = client.watchlist()

# Remove a compound
client.watchlist_remove("hq-c-org-000033")

Changelog (Developer+)

# Recent regulatory/data changes
changes = client.changelog(limit=20)

# Filter by date and compound
changes = client.changelog(since="2026-03-01", compound_id="hq-c-org-000001")

Raw data access (Developer+)

raw = client.compound_raw("hq-c-org-000001")
raw_product = client.product_raw("hq-p-hom-000001")

Tiers

Tier Requests/Day Price
Public 500/IP Free
Developer 10,000 $29/mo
Pro 100,000 $99/mo
Enterprise Unlimited Contact

Get an API key at aletheia.holisticquality.io/pricing.

Error Handling

from aletheia_safety import Aletheia, AletheiaError, RateLimitError

client = Aletheia()

try:
    compound = client.compound("invalid-id")
except RateLimitError:
    print("Rate limit exceeded — wait or upgrade your tier")
except AletheiaError as e:
    print(f"API error {e.status}: {e}")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aletheia_safety-0.8.0.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aletheia_safety-0.8.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file aletheia_safety-0.8.0.tar.gz.

File metadata

  • Download URL: aletheia_safety-0.8.0.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for aletheia_safety-0.8.0.tar.gz
Algorithm Hash digest
SHA256 cafce4c3de0df6f18f5c3e49f89562107d4dece3d5148dd3433f88bb8773faf8
MD5 4184ad1a05c6d7acef6df0e344cb9d71
BLAKE2b-256 1a773dc87035b4873f06196e827f0fde460e47e4c023bd73858101c0836d6de8

See more details on using hashes here.

File details

Details for the file aletheia_safety-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aletheia_safety-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbdc68676563010bfb24ee3c5b0a15934d0c4ab17117038b5c2095979fd6a0b6
MD5 c31807b71b604ead28ac45d8d05e470f
BLAKE2b-256 da3a4fb114921546397e2dca72154c36c9881a51e4b09c401b91b975678ab37a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page