$npx -y skills add ai4protein/VenusFactory2 --skill fdaQuery openFDA API for drugs, devices, adverse events, recalls, regulatory submissions (510k, PMA), substance identification (UNII), for FDA regulatory data analysis and safety research.
| 1 | # FDA Database Access |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Access comprehensive FDA regulatory data through openFDA, the FDA's initiative to provide open APIs for public datasets. Query information about drugs, medical devices, foods, animal/veterinary products, and substances using Python with standardized interfaces. |
| 6 | |
| 7 | **Key capabilities:** |
| 8 | - Query adverse events for drugs, devices, foods, and veterinary products |
| 9 | - Access product labeling, approvals, and regulatory submissions |
| 10 | - Monitor recalls and enforcement actions |
| 11 | - Look up National Drug Codes (NDC) and substance identifiers (UNII) |
| 12 | - Analyze device classifications and clearances (510k, PMA) |
| 13 | - Track drug shortages and supply issues |
| 14 | - Research chemical structures and substance relationships |
| 15 | |
| 16 | ## When to Use This Skill |
| 17 | |
| 18 | This skill should be used when working with: |
| 19 | - **Drug research**: Safety profiles, adverse events, labeling, approvals, shortages |
| 20 | - **Medical device surveillance**: Adverse events, recalls, 510(k) clearances, PMA approvals |
| 21 | - **Food safety**: Recalls, allergen tracking, adverse events, dietary supplements |
| 22 | - **Veterinary medicine**: Animal drug adverse events by species and breed |
| 23 | - **Chemical/substance data**: UNII lookup, CAS number mapping, molecular structures |
| 24 | - **Regulatory analysis**: Approval pathways, enforcement actions, compliance tracking |
| 25 | - **Pharmacovigilance**: Post-market surveillance, safety signal detection |
| 26 | - **Scientific research**: Drug interactions, comparative safety, epidemiological studies |
| 27 | |
| 28 | ## Quick Start |
| 29 | |
| 30 | ### 1. Project Scripts and Import |
| 31 | |
| 32 | Scripts live in `src/tools/search/deepsearch/fda/`. Each module is runnable with `python -m src.tools.search.deepsearch.fda.<module>`. |
| 33 | |
| 34 | | Script | Purpose | Main | |
| 35 | |--------|---------|------| |
| 36 | | `fda_query.py` | Full `FDAQuery` class: all categories (drug, device, food, animal, substance), rate limit, cache | Yes | |
| 37 | | `fda_examples.py` | Comprehensive examples: drug safety, device surveillance, food recalls, substance, comparative, veterinary | Yes | |
| 38 | | `fda_drug.py` | Drug-only demo: events, label, recalls | Yes | |
| 39 | | `fda_device.py` | Device-only demo: events, 510k, classification | Yes | |
| 40 | | `fda_substance.py` | Substance demo: by name, by UNII | Yes | |
| 41 | |
| 42 | Import the client: |
| 43 | |
| 44 | ```python |
| 45 | from src.tools.search.deepsearch.fda import FDAQuery |
| 46 | |
| 47 | # Initialize (API key optional but recommended) |
| 48 | fda = FDAQuery(api_key="YOUR_API_KEY") |
| 49 | |
| 50 | # Query drug adverse events |
| 51 | events = fda.query_drug_events("aspirin", limit=100) |
| 52 | |
| 53 | # Get drug labeling |
| 54 | label = fda.query_drug_label("Lipitor", brand=True) |
| 55 | |
| 56 | # Search device recalls |
| 57 | recalls = fda.query("device", "enforcement", |
| 58 | search="classification:Class+I", |
| 59 | limit=50) |
| 60 | ``` |
| 61 | |
| 62 | ### 2. API Key Setup |
| 63 | |
| 64 | While the API works without a key, registering provides higher rate limits: |
| 65 | - **Without key**: 240 requests/min, 1,000/day |
| 66 | - **With key**: 240 requests/min, 120,000/day |
| 67 | |
| 68 | Register at: https://open.fda.gov/apis/authentication/ |
| 69 | |
| 70 | Set as environment variable: |
| 71 | ```bash |
| 72 | export FDA_API_KEY="your_key_here" |
| 73 | ``` |
| 74 | |
| 75 | ### 3. Running Scripts (each has `if __name__ == "__main__"`) |
| 76 | |
| 77 | ```bash |
| 78 | # Full query module (minimal drug/label examples) |
| 79 | python -m src.tools.search.deepsearch.fda.fda_query |
| 80 | |
| 81 | # Comprehensive examples (drug, device, food, substance, comparative, veterinary) |
| 82 | python -m src.tools.search.deepsearch.fda.fda_examples |
| 83 | |
| 84 | # Domain-specific demos |
| 85 | python -m src.tools.search.deepsearch.fda.fda_drug |
| 86 | python -m src.tools.search.deepsearch.fda.fda_device |
| 87 | python -m src.tools.search.deepsearch.fda.fda_substance |
| 88 | ``` |
| 89 | |
| 90 | ## FDA Database Categories |
| 91 | |
| 92 | ### Drugs |
| 93 | |
| 94 | Access 6 drug-related endpoints covering the full drug lifecycle from approval to post-market surveillance. |
| 95 | |
| 96 | **Endpoints:** |
| 97 | 1. **Adverse Events** - Reports of side effects, errors, and therapeutic failures |
| 98 | 2. **Product Labeling** - Prescribing information, warnings, indications |
| 99 | 3. **NDC Directory** - National Drug Code product information |
| 100 | 4. **Enforcement Reports** - Drug recalls and safety actions |
| 101 | 5. **Drugs@FDA** - Historical approval data since 1939 |
| 102 | 6. **Drug Shortages** - Current and resolved supply issues |
| 103 | |
| 104 | **Common use cases:** |
| 105 | ```python |
| 106 | from src.tools.search.deepsearch.fda import FDAQuery |
| 107 | fda = FDAQuery(api_key="YOUR_API_KEY") |
| 108 | |
| 109 | # Safety signal detection |
| 110 | fda.count_by_field("drug", "event", |
| 111 | search="patient.drug.medicinalproduct:metformin", |
| 112 | field="patient.reaction.reactionmeddrapt") |
| 113 | |
| 114 | # Get prescribing information |
| 115 | label = fda.query_drug_label("Keytruda", brand=True) |
| 116 | |
| 117 | # Check for recalls |
| 118 | recalls = fda.query_drug_recalls(drug_name="metformin") |
| 119 | |
| 120 | # Monitor shortages |
| 121 | shortages = fda.query("drug", "drugshortages", |
| 122 | search="status:Currently+in+Shortage") |
| 123 | ``` |
| 124 | |
| 125 | **Reference:** See `references/drugs.md` for de |