$npx -y skills add QSong-github/DrugClaw --skill cpic> Clinical Pharmacogenomics Implementation Consortium — gene-based prescribing guidelines > Category: Drug-centric | Type: DB | Subcategory: Drug Knowledgebase > API: https://api.cpicpgx.org/v1 (PostgREST, free, no key required)
| 1 | # 67 · CPIC |
| 2 | |
| 3 | > Clinical Pharmacogenomics Implementation Consortium — gene-based prescribing guidelines |
| 4 | > **Category:** Drug-centric | **Type:** DB | **Subcategory:** Drug Knowledgebase |
| 5 | > **API:** `https://api.cpicpgx.org/v1` (PostgREST, free, no key required) |
| 6 | |
| 7 | | Resource | URL | |
| 8 | |----------|-----| |
| 9 | | Homepage | https://cpicpgx.org/ | |
| 10 | | API / Data | https://cpicpgx.org/cpic-data/ | |
| 11 | | Paper | https://pubmed.ncbi.nlm.nih.gov/33479744/ | |
| 12 | |
| 13 | --- |
| 14 | |
| 15 | ## What it provides |
| 16 | |
| 17 | - **Drug metadata**: drugid (RxNorm), DrugBank ID, ATC codes, flowchart links |
| 18 | - **Guidelines**: peer-reviewed pharmacogenomics prescribing guidelines (drug + gene → dosing advice) |
| 19 | - **Gene-drug pairs**: curated pairs with CPIC level, PharmGKB level, PGx testing status |
| 20 | - **Dosing recommendations**: phenotype-specific dosing adjustments per drug-gene combination |
| 21 | |
| 22 | --- |
| 23 | |
| 24 | ## API schema note |
| 25 | |
| 26 | The `pair` and `recommendation` tables use **`drugid`** (e.g. `RxNorm:32968`), not drug name. |
| 27 | This script resolves drug names automatically via the `/v1/drug` table before querying. |
| 28 | |
| 29 | Guideline lookup uses two strategies: (1) name substring match, (2) `guidelineid` from the drug table. |
| 30 | This is necessary because some guidelines use class names (e.g. simvastatin → `"SLCO1B1, ABCG2, CYP2C9, and Statins"`, codeine → `"CYP2D6, OPRM1, COMT, and Opioids"`). |
| 31 | |
| 32 | --- |
| 33 | |
| 34 | ## Quick start |
| 35 | |
| 36 | ```python |
| 37 | from 67_CPIC import query |
| 38 | |
| 39 | # Single drug |
| 40 | results = query("clopidogrel") |
| 41 | |
| 42 | # Multiple drugs |
| 43 | results = query(["warfarin", "codeine"]) |
| 44 | |
| 45 | # Query by gene symbol |
| 46 | results = query("CYP2D6", fields="pairs") |
| 47 | |
| 48 | # Specific fields only |
| 49 | results = query("codeine", fields="guidelines") |
| 50 | results = query("codeine", fields="recommendations") |
| 51 | ``` |
| 52 | |
| 53 | --- |
| 54 | |
| 55 | ## `query()` interface |
| 56 | |
| 57 | ``` |
| 58 | query(entities, fields="all") -> list[dict] |
| 59 | ``` |
| 60 | |
| 61 | | Parameter | Type | Description | |
| 62 | |------------|--------------------|-------------| |
| 63 | | `entities` | `str \| list[str]` | Drug name(s) or gene symbol(s) | |
| 64 | | `fields` | `str` | `"all"` — everything; `"guidelines"` / `"pairs"` / `"recommendations"` | |
| 65 | |
| 66 | ### Return structure (`fields="all"`) |
| 67 | |
| 68 | ```json |
| 69 | [ |
| 70 | { |
| 71 | "query": "clopidogrel", |
| 72 | "drug_info": [ |
| 73 | {"drugid": "RxNorm:32968", "name": "clopidogrel", |
| 74 | "drugbankid": "DB00758", "atcid": ["B01AC04"], "flowchart": "..."} |
| 75 | ], |
| 76 | "guidelines": [ |
| 77 | {"name": "CYP2C19 and Clopidogrel", "url": "...", "version": 66} |
| 78 | ], |
| 79 | "gene_drug_pairs": [ |
| 80 | {"genesymbol": "CYP2C19", "drugid": "RxNorm:32968", |
| 81 | "cpiclevel": "A", "clinpgxlevel": "1A", |
| 82 | "pgxtesting": "Actionable PGx", "citations": ["21716271", ...]} |
| 83 | ], |
| 84 | "recommendations": [ |
| 85 | {"drugid": "RxNorm:32968", |
| 86 | "phenotypes": {"CYP2C19": "Ultrarapid Metabolizer"}, |
| 87 | "implications": {"CYP2C19": "Increased active metabolite ..."}, |
| 88 | "recommendation": "Use at standard dose (75 mg/day)", |
| 89 | "classification": "Strong", |
| 90 | "population": "CVI ACS PCI"} |
| 91 | ] |
| 92 | } |
| 93 | ] |
| 94 | ``` |
| 95 | |
| 96 | On error: `{"query": "xxx", "error": "..."}`. |
| 97 | |
| 98 | --- |
| 99 | |
| 100 | ## Lower-level functions |
| 101 | |
| 102 | | Function | Input | Output | Description | |
| 103 | |----------|-------|--------|-------------| |
| 104 | | `get_drug_info(drug_name)` | drug name | `list[dict]` | Drug table lookup (fuzzy) | |
| 105 | | `get_guidelines(drug_name=None)` | optional drug name | `list[dict]` | All or filtered guidelines | |
| 106 | | `get_gene_drug_pairs(drug_name=None, gene=None)` | optional filters | `list[dict]` | Gene-drug pairs (name auto-resolved to drugid) | |
| 107 | | `get_recommendations(drug_name)` | drug name | `list[dict]` | Dosing recommendations (name auto-resolved) | |
| 108 | |
| 109 | --- |
| 110 | |
| 111 | ## Notes |
| 112 | |
| 113 | - CPIC levels: **A** = guideline published, **B** = in progress, **C/D** = lower evidence. |
| 114 | - Gene symbols are auto-detected (uppercase, ≤12 chars) and routed to `genesymbol` filter. |
| 115 | - Drug names are fuzzy-matched via `ilike` on the `/v1/drug` table. |
| 116 | - No rate limit documented, but keep requests reasonable. |