[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73HZGRK81Q06545YB4RXDGX":3,"skill-same:01M73HZGRK81Q06545YB4RXDGX":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":33,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M73HZGRK81Q06545YB4RXDGX","pubchem-compound-search",null,"Query PubChem (110M+ compounds) directly via the PUG-REST\u002FJSON API with plain `requests` — no SDK install required. Search by name\u002FCID\u002FSMILES\u002FInChIKey\u002Fformula, retrieve properties (MW, XLogP, TPSA, H-bond counts), do similarity\u002Fsubstructure searches with async ListKey polling, fetch synonyms, descriptions, assay summaries, and download SDF\u002FPNG. For local cheminformatics use rdkit; for bioactivity-centric workflows use chembl-database-bioactivity.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"CC-BY-4.0","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fpubchem-compound-search\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: \"pubchem-compound-search\"\ndescription: \"Query PubChem (110M+ compounds) directly via the PUG-REST\u002FJSON API with plain `requests` — no SDK install required. Search by name\u002FCID\u002FSMILES\u002FInChIKey\u002Fformula, retrieve properties (MW, XLogP, TPSA, H-bond counts), do similarity\u002Fsubstructure searches with async ListKey polling, fetch synonyms, descriptions, assay summaries, and download SDF\u002FPNG. For local cheminformatics use rdkit; for bioactivity-centric workflows use chembl-database-bioactivity.\"\nlicense: \"CC-BY-4.0\"\nmetadata:\n  quick_use: 'one compound: GET https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fname\u002F{name}\u002Fproperty\u002FSMILES,ConnectivitySMILES,MolecularFormula,MolecularWeight,IUPACName\u002FJSON (or compound\u002Fcid\u002F{CID}\u002F...) -> r.json()[''PropertyTable''][''Properties''][0]. Response keys are `SMILES` (isomeric) and `ConnectivitySMILES`; `CanonicalSMILES`\u002F`IsomericSMILES` never come back, even when requested. Unknown name -> 404 (PUGREST.NotFound). 2D image: ...\u002Fcompound\u002Fname\u002F{name}\u002FPNG. Cite https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fcompound\u002F{CID}'\n---\n\n# PubChem Compound Search\n\n## Overview\n\nPubChem (NCBI) is the largest freely available chemical database — 110M+ compounds, 280M+ substances, and millions of bioassay records. Its **PUG-REST JSON API** is the canonical programmatic surface, and every example here uses it directly via plain `requests`. The Python `pubchempy` wrapper is *not* required; the PUG-REST URL grammar is small enough that direct calls are more transparent, easier to retry\u002Fcache, and avoid sandbox dependency issues (the library is not in `TOOL_STATUS.md`).\n\nThe URL pattern is fixed and predictable:\n\n```\nhttps:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002F\u003Cinput>\u002F\u003Coperation>\u002F\u003Coutput>\n```\n\n- `\u003Cinput>`   = `compound\u002F{name,cid,smiles,inchikey,formula}\u002F\u003Cvalue>`\n- `\u003Coperation>` = `cids`, `property\u002F\u003Clist>`, `synonyms`, `description`, `assaysummary`, `JSON` (full record), `SDF`, `PNG`\n- `\u003Coutput>`  = `JSON`, `CSV`, `TXT`, `SDF`, `PNG`\n\nFor long-running operations (similarity, substructure, formula) the API returns HTTP 202 + `{\"Waiting\": {\"ListKey\": \"...\"}}`; poll `compound\u002Flistkey\u002F{key}\u002Fcids\u002FJSON` until it returns `IdentifierList`. The skill handles this pattern in Module 4.\n\n## When to Use\n\n- Looking up a compound by name, SMILES, InChIKey, or formula to get its PubChem CID\n- Retrieving molecular properties (molecular weight, XLogP, TPSA, H-bond donor\u002Facceptor counts, rotatable bonds, formula, IUPAC name) for one or many CIDs in a single request\n- Finding structurally similar compounds via Tanimoto similarity (async ListKey poll)\n- Searching for compounds containing a substructure \u002F pharmacophore motif\n- Fetching every synonym \u002F trade name \u002F CAS number for a CID\n- Pulling assay summary tables (active\u002Finactive screening results) for a compound\n- Converting between identifier formats (name ↔ CID ↔ SMILES ↔ InChI ↔ InChIKey) in one API call\n- Downloading 2D SDF or PNG structures for figures or downstream RDKit work\n- For local cheminformatics (fingerprints, descriptors, 3D conformers, scaffold extraction) use `rdkit`\n- For deeper bioactivity \u002F target-binding data (IC50, Ki against specific targets) use `chembl-database-bioactivity`\n\n## Prerequisites\n\n- **Python packages**: `requests`, `pandas` — both already in standard environments\n- **No API key required** — PubChem is fully public\n- **Rate limits**: max 5 requests\u002Fsecond and 400 requests\u002Fminute per IP. Throttle with `time.sleep(0.25)` in loops; return code 503 means you tripped the limit.\n\nIf you are inside a pixi\u002Fconda environment that already provides `requests` and `pandas`, skip the install and invoke scripts with `pixi run python ...`.\n\n```bash\npip install requests pandas\n```\n\n## Quick Start\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# name → CID\ncid = requests.get(f\"{BASE}\u002Fcompound\u002Fname\u002Faspirin\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"][0]\n\n# CID → properties (single call, many fields)\nr = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002Fproperty\u002F\"\n    \"MolecularWeight,XLogP,TPSA,HBondDonorCount,HBondAcceptorCount,SMILES,IUPACName\u002FJSON\")\np = r.json()[\"PropertyTable\"][\"Properties\"][0]\nprint(f\"CID {cid} — {p['IUPACName']}\")\nprint(f\"  MW={p['MolecularWeight']}  XLogP={p['XLogP']}  TPSA={p['TPSA']}\")\nprint(f\"  HBD={p['HBondDonorCount']}  HBA={p['HBondAcceptorCount']}\")\nprint(f\"  SMILES={p['SMILES']}\")\n```\n\n## Core API\n\n### Module 1: Identifier lookup\n\nResolve any external identifier to a PubChem CID via `\u002Fcompound\u002F{namespace}\u002F{value}\u002Fcids\u002FJSON`. Namespaces: `name`, `cid`, `smiles`, `inchikey`, `inchi`, `formula`.\n\n```python\nimport requests\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# By name (returns all matching CIDs as a list)\ncids = requests.get(f\"{BASE}\u002Fcompound\u002Fname\u002Fcaffeine\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"]\nprint(f\"caffeine CIDs: {cids}\")\n\n# By canonical SMILES (URL-encode!)\nsmi = quote(\"CC(=O)OC1=CC=CC=C1C(=O)O\", safe=\"\")\ncid = requests.get(f\"{BASE}\u002Fcompound\u002Fsmiles\u002F{smi}\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"][0]\nprint(f\"aspirin SMILES → CID {cid}\")\n\n# By InChIKey (exact match, fastest if you already have one)\nikey = \"BSYNRYMUTXBXSQ-UHFFFAOYSA-N\"\ncid = requests.get(f\"{BASE}\u002Fcompound\u002Finchikey\u002F{ikey}\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"][0]\nprint(f\"InChIKey → CID {cid}\")\n```\n\n### Module 2: Property retrieval\n\n`\u002Fcompound\u002Fcid\u002F{cid_or_csv}\u002Fproperty\u002F\u003Ccsv-list>\u002FJSON` returns all requested properties in one round trip. **CIDs and property names are both CSV-joinable** — batch up to ~200 CIDs and many properties at once.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# Full property set for a single compound (ibuprofen CID 3672)\nurl = (f\"{BASE}\u002Fcompound\u002Fcid\u002F3672\u002Fproperty\u002F\"\n       \"MolecularWeight,XLogP,TPSA,HBondDonorCount,HBondAcceptorCount,\"\n       \"RotatableBondCount,SMILES,InChIKey,IUPACName,MolecularFormula\u002FJSON\")\np = requests.get(url).json()[\"PropertyTable\"][\"Properties\"][0]\nprint(f\"{p['IUPACName']}  formula={p['MolecularFormula']}\")\nprint(f\"  MW={p['MolecularWeight']} XLogP={p['XLogP']} TPSA={p['TPSA']}\")\nprint(f\"  HBD={p['HBondDonorCount']} HBA={p['HBondAcceptorCount']} RotB={p['RotatableBondCount']}\")\n```\n\n```python\nimport requests, pandas as pd\n\n# Batch: 4 CIDs, 3 properties — one request, one round trip\ncids = \"2244,3672,2157,2662\"   # aspirin, ibuprofen, naproxen, celecoxib\nr = requests.get(\n    f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F{cids}\u002Fproperty\u002F\"\n    \"MolecularWeight,XLogP,TPSA\u002FJSON\")\ndf = pd.DataFrame(r.json()[\"PropertyTable\"][\"Properties\"])\nprint(df.to_string(index=False))\n```\n\n### Module 3: Synonyms and description\n\nSynonyms (trade names, CAS numbers, alternative spellings) and curated descriptions live at `\u002Fcompound\u002F{ns}\u002F{value}\u002F{synonyms|description}\u002FJSON`.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# Full synonym list (aspirin has ~700)\ninfo = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F2244\u002Fsynonyms\u002FJSON\").json()[\"InformationList\"][\"Information\"][0]\nprint(f\"aspirin synonyms: {len(info['Synonym'])}\")\nfor s in info[\"Synonym\"][:8]:\n    print(f\"  {s}\")\n```\n\n```python\nimport requests\n\n# Curated descriptions (NCBI MeSH, CAMEO, etc.)\nr = requests.get(\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fname\u002Faspirin\u002Fdescription\u002FJSON\")\nfor item in r.json()[\"InformationList\"][\"Information\"]:\n    if \"Description\" in item:\n        print(f\"[{item.get('DescriptionSourceName','?')}]\")\n        print(f\"  {item['Description'][:200]}…\")\n        print()\n```\n\n### Module 4: Similarity & substructure search (async ListKey pattern)\n\nStructure searches return HTTP 202 + `{\"Waiting\": {\"ListKey\": \"...\"}}`. Poll `\u002Fcompound\u002Flistkey\u002F{key}\u002Fcids\u002FJSON` every ~2s until it returns `IdentifierList`. Wrap this in a helper since it's used everywhere.\n\n```python\nimport requests, time\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndef poll_listkey(listkey, max_polls=10, interval=2.0):\n    \"\"\"Block until PubChem finishes async search; return CID list.\"\"\"\n    for _ in range(max_polls):\n        time.sleep(interval)\n        j = requests.get(f\"{BASE}\u002Fcompound\u002Flistkey\u002F{listkey}\u002Fcids\u002FJSON\", timeout=20).json()\n        if \"IdentifierList\" in j:\n            return j[\"IdentifierList\"][\"CID\"]\n    raise TimeoutError(f\"ListKey {listkey} did not complete\")\n\n# Tanimoto similarity (90% threshold, max 20 hits) — starting from aspirin SMILES\nsmi = quote(\"CC(=O)OC1=CC=CC=C1C(=O)O\", safe=\"\")\ninit = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fsimilarity\u002Fsmiles\u002F{smi}\u002FJSON?Threshold=90&MaxRecords=20\").json()\ncids = poll_listkey(init[\"Waiting\"][\"ListKey\"]) if \"Waiting\" in init \\\n       else init[\"IdentifierList\"][\"CID\"]\nprint(f\"aspirin @90% similarity: {len(cids)} hits, sample={cids[:5]}\")\n```\n\n```python\nimport requests\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# Substructure search — all compounds containing a sulfonamide group\nsmi = quote(\"S(=O)(=O)N\", safe=\"\")\ninit = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fsubstructure\u002Fsmiles\u002F{smi}\u002FJSON?MaxRecords=20\").json()\ncids = poll_listkey(init[\"Waiting\"][\"ListKey\"]) if \"Waiting\" in init \\\n       else init[\"IdentifierList\"][\"CID\"]\nprint(f\"sulfonamide-containing CIDs: {len(cids)}, sample={cids[:5]}\")\n```\n\n### Module 5: Assay summary (bioactivity data)\n\n`\u002Fcompound\u002Fcid\u002F{cid}\u002Fassaysummary\u002FJSON` returns a `Table` of every PubChem BioAssay the compound appears in (assay AID, target, outcome, micromolar activity if available).\n\n```python\nimport requests, pandas as pd\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\nr = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F2244\u002Fassaysummary\u002FJSON\", timeout=30)\nrows = r.json().get(\"Table\", {}).get(\"Row\", [])\ncols = r.json().get(\"Table\", {}).get(\"Columns\", {}).get(\"Column\", [])\nprint(f\"aspirin appears in {len(rows)} bioassays\")\n\n# First few columns + rows as a DataFrame\ndf = pd.DataFrame([row[\"Cell\"] for row in rows[:5]], columns=cols)\nprint(df.iloc[:, :6].to_string(index=False))\n```\n\n### Module 6: Structure file download (SDF \u002F PNG)\n\n`\u002Fcompound\u002Fcid\u002F{cid}\u002FSDF` returns 2D MOL\u002FSDF; `\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG` returns a structure image (use `?image_size=large` for higher resolution).\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\ncid = 2519   # caffeine\n\n# 2D SDF for downstream RDKit \u002F OpenBabel\nsdf = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002FSDF\", timeout=15).text\nwith open(\"caffeine.sdf\", \"w\") as f:\n    f.write(sdf)\nprint(f\"caffeine.sdf: {len(sdf)} chars, ends with M  END={'M  END' in sdf}\")\n\n# PNG structure image\npng = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG?image_size=large\", timeout=15).content\nwith open(\"caffeine.png\", \"wb\") as f:\n    f.write(png)\nprint(f\"caffeine.png: {len(png)} bytes\")\n```\n\n## Key Concepts\n\n### Async ListKey pattern\n\nSimilarity, substructure, and formula searches are **asynchronous** — the API kicks off a background job and returns HTTP 202 with `{\"Waiting\": {\"ListKey\": \"\u003Cid>\"}}`. Poll `\u002Fcompound\u002Flistkey\u002F{id}\u002Fcids\u002FJSON` every ~2 seconds until the response contains `IdentifierList`. Most searches finish in 5–15s; tighten polling for tiny searches, loosen for very large ones. Use the `poll_listkey` helper from Module 4 everywhere.\n\nA small fraction of fast searches return `IdentifierList` directly on the first call (no `Waiting` field); check for both possibilities.\n\n### Property name reference\n\n| API name              | Meaning                                   |\n| --------------------- | ----------------------------------------- |\n| `MolecularWeight`     | Molecular weight (g\u002Fmol, string)          |\n| `MolecularFormula`    | Hill-system formula                       |\n| `SMILES`              | Isomeric SMILES, with stereochemistry (2025+ name; was `IsomericSMILES`) |\n| `ConnectivitySMILES`  | Connectivity-only SMILES, no stereo (2025+ name; was `CanonicalSMILES`) |\n| `IUPACName`           | Curated IUPAC name                        |\n| `InChI` \u002F `InChIKey`  | IUPAC InChI \u002F InChIKey                    |\n| `XLogP`               | Computed logP (octanol\u002Fwater)             |\n| `TPSA`                | Topological polar surface area (Å²)       |\n| `HBondDonorCount`     | Number of H-bond donors                   |\n| `HBondAcceptorCount`  | Number of H-bond acceptors                |\n| `RotatableBondCount`  | Number of rotatable bonds                 |\n| `HeavyAtomCount`      | Non-hydrogen atom count                   |\n| `Charge`              | Formal charge                             |\n\nCSV-join any subset in a single `\u002Fproperty\u002F\u003Ccsv>\u002FJSON` URL. Note that `MolecularWeight` returns as a string; cast to `float` before arithmetic.\n\n### Response envelope shapes\n\n- `cids\u002FJSON`             → `{\"IdentifierList\": {\"CID\": [int, ...]}}`\n- `property\u002F...\u002FJSON`     → `{\"PropertyTable\": {\"Properties\": [{...}, ...]}}` (one dict per CID, in input order)\n- `synonyms\u002FJSON`         → `{\"InformationList\": {\"Information\": [{\"CID\": int, \"Synonym\": [str, ...]}]}}`\n- `description\u002FJSON`      → `{\"InformationList\": {\"Information\": [{\"CID\": int, \"Description\": str, \"DescriptionSourceName\": str, ...}, ...]}}`\n- `assaysummary\u002FJSON`     → `{\"Table\": {\"Columns\": {\"Column\": [...]}, \"Row\": [{\"Cell\": [...]}, ...]}}`\n- async-init (similarity, substructure, formula) → 202 with `{\"Waiting\": {\"ListKey\": \"...\"}}`\n- listkey poll            → `{\"IdentifierList\": {\"CID\": [...]}}` when ready\n\n## Common Workflows\n\n### Workflow 1: Property comparison across a drug panel\n\n**Goal**: side-by-side physicochemical comparison of a small molecule set.\n\n```python\nimport requests, pandas as pd, time\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndrugs = [\"aspirin\", \"ibuprofen\", \"naproxen\", \"celecoxib\"]\n\n# Resolve names → CIDs in a loop (rate-limited)\ncids = []\nfor d in drugs:\n    cid = requests.get(f\"{BASE}\u002Fcompound\u002Fname\u002F{quote(d)}\u002Fcids\u002FJSON\",\n                       timeout=15).json()[\"IdentifierList\"][\"CID\"][0]\n    cids.append(cid)\n    time.sleep(0.25)\n\n# Single batched property pull\ncid_csv = \",\".join(str(c) for c in cids)\nr = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid_csv}\u002Fproperty\u002F\"\n    \"MolecularWeight,XLogP,TPSA,HBondDonorCount,HBondAcceptorCount\u002FJSON\")\ndf = pd.DataFrame(r.json()[\"PropertyTable\"][\"Properties\"])\ndf[\"Name\"] = drugs\ndf = df[[\"Name\", \"CID\", \"MolecularWeight\", \"XLogP\", \"TPSA\",\n         \"HBondDonorCount\", \"HBondAcceptorCount\"]]\nprint(df.to_string(index=False))\n```\n\n### Workflow 2: Lead compound → similar analogs → properties\n\n**Goal**: starting from a kinase inhibitor (gefitinib), find 85%-similar analogs and pull their properties.\n\n```python\nimport requests, time\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndef poll_listkey(listkey, max_polls=10, interval=2.0):\n    for _ in range(max_polls):\n        time.sleep(interval)\n        j = requests.get(f\"{BASE}\u002Fcompound\u002Flistkey\u002F{listkey}\u002Fcids\u002FJSON\",\n                         timeout=20).json()\n        if \"IdentifierList\" in j:\n            return j[\"IdentifierList\"][\"CID\"]\n    raise TimeoutError(\"listkey timeout\")\n\n# 1. lead → CID → canonical SMILES\nref_cid = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fname\u002Fgefitinib\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"][0]\nref_smi = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fcid\u002F{ref_cid}\u002Fproperty\u002FSMILES\u002FJSON\"\n    ).json()[\"PropertyTable\"][\"Properties\"][0][\"SMILES\"]\nprint(f\"gefitinib CID={ref_cid}  SMILES={ref_smi}\")\n\n# 2. similarity search\nsmi_q = quote(ref_smi, safe=\"\")\ninit = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fsimilarity\u002Fsmiles\u002F{smi_q}\u002FJSON?Threshold=85&MaxRecords=15\"\n    ).json()\nsim_cids = poll_listkey(init[\"Waiting\"][\"ListKey\"]) if \"Waiting\" in init \\\n           else init[\"IdentifierList\"][\"CID\"]\nprint(f\"  {len(sim_cids)} analogs @85% Tanimoto\")\n\n# 3. batch-pull properties for top 5 analogs\ncid_csv = \",\".join(str(c) for c in sim_cids[:5])\nr = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid_csv}\u002Fproperty\u002F\"\n    \"MolecularWeight,XLogP,TPSA,RotatableBondCount\u002FJSON\")\nfor row in r.json()[\"PropertyTable\"][\"Properties\"]:\n    print(f\"  CID {row['CID']}: MW={row['MolecularWeight']} XLogP={row['XLogP']}\")\n```\n\n### Workflow 3: Pharmacophore screen via substructure → bioactivity check\n\n**Goal**: find compounds with a sulfonamide motif and check which have bioactivity records.\n\n```python\nimport requests, time\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndef poll_listkey(listkey, max_polls=10, interval=2.0):\n    for _ in range(max_polls):\n        time.sleep(interval)\n        j = requests.get(f\"{BASE}\u002Fcompound\u002Flistkey\u002F{listkey}\u002Fcids\u002FJSON\",\n                         timeout=20).json()\n        if \"IdentifierList\" in j:\n            return j[\"IdentifierList\"][\"CID\"]\n    raise TimeoutError(\"listkey timeout\")\n\nsmi = quote(\"S(=O)(=O)N\", safe=\"\")\ninit = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fsubstructure\u002Fsmiles\u002F{smi}\u002FJSON?MaxRecords=10\").json()\ncids = poll_listkey(init[\"Waiting\"][\"ListKey\"]) if \"Waiting\" in init \\\n       else init[\"IdentifierList\"][\"CID\"]\nprint(f\"sulfonamide CIDs: {cids}\")\n\n# Bioactivity row counts for the first few hits\nfor cid in cids[:3]:\n    rows = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002Fassaysummary\u002FJSON\",\n                        timeout=30).json().get(\"Table\", {}).get(\"Row\", [])\n    print(f\"  CID {cid}: {len(rows)} assay rows\")\n    time.sleep(0.3)\n```\n\n## Key Parameters\n\n| Parameter         | Endpoint \u002F Module                | Default | Range \u002F Options                            | Effect                                                                  |\n| ----------------- | -------------------------------- | ------- | ------------------------------------------ | ----------------------------------------------------------------------- |\n| `\u003Cnamespace>`     | `\u002Fcompound\u002F{ns}\u002F\u003Cvalue>\u002F...`     | —       | `name`, `cid`, `smiles`, `inchikey`, `inchi`, `formula` | Input identifier type                                                  |\n| `\u003Cproperty csv>`  | `\u002F...\u002Fproperty\u002F\u003Ccsv>\u002FJSON`       | —       | any subset of property names (see table)   | Which properties to return (one DB call per request)                    |\n| `Threshold`       | similarity (M4)                  | `90`    | `0`–`100`                                  | Tanimoto cutoff (percent)                                               |\n| `MaxRecords`      | similarity \u002F substructure \u002F formula | (server-side default) | `1`–`10000`                       | Cap on async result list                                                |\n| `image_size`      | `\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG`        | medium  | `small`, `large`, `WxH` (e.g. `500x500`)   | PNG output resolution                                                   |\n| `record_type`     | `\u002Fcompound\u002Fcid\u002F{cid}\u002FSDF`        | `2d`    | `2d`, `3d`                                 | SDF dimensionality (`?record_type=3d`)                                  |\n| `MaxAssayResults` | `\u002Fcompound\u002Fcid\u002F{cid}\u002Fassaysummary\u002FJSON` | —    | int                                        | Limit assay rows when compound has thousands of records                 |\n\n## Best Practices\n\n1. **Always go through `cids\u002FJSON` first** when starting from a name or external identifier. The name→CID resolution and the CID→property lookup are separate calls; doing both at once via `name → property` works but throws away the canonical CID list that downstream queries need.\n\n2. **Batch properties, never loop them.** `compound\u002Fcid\u002F2244,3672,2157,...\u002Fproperty\u002FMolecularWeight,XLogP,...\u002FJSON` accepts up to ~200 CIDs and any number of properties — one round trip instead of N. Looping `get_compounds` per name is the most common rate-limit trap.\n\n3. **URL-encode every SMILES.** Use `urllib.parse.quote(smiles, safe=\"\")`. Bare SMILES with `=`, `#`, `(`, `)`, `[`, `]` will sometimes work but breaks unpredictably on `+`, `\u002F`, `\\`, or query-string-looking substrings.\n\n4. **Treat similarity\u002Fsubstructure\u002Fformula as async.** Branch on `\"Waiting\" in response` and poll `listkey` rather than re-issuing the search. Re-issuing creates a new ListKey and wastes the server's job slot.\n\n5. **Throttle ≤ 5 req\u002Fsec, ≤ 400\u002Fmin.** Insert `time.sleep(0.25)` in any tight loop. HTTP 503 means you tripped the limit — wait 10s and reduce concurrency.\n\n6. **Cast `MolecularWeight` to `float`.** It's returned as a string (`\"180.16\"`) for full decimal fidelity. Comparing strings against numeric thresholds is a silent bug.\n\n7. **For 100+ CIDs use POST.** GET URLs over ~2000 chars get truncated by some HTTP proxies. PubChem also accepts `POST` with `cid` in the form body: `requests.post(f\"{BASE}\u002Fcompound\u002Fcid\u002Fproperty\u002FMolecularWeight\u002FJSON\", data={\"cid\": cid_csv})`.\n\n8. **2025 SMILES property rename.** PubChem renamed two SMILES properties in the 2025 PUG-REST schema: old `IsomericSMILES` (with stereo) → `SMILES`, and old `CanonicalSMILES` (connectivity only, no stereo) → `ConnectivitySMILES`. The URL path still accepts the legacy names as *input* (e.g. `\u002Fproperty\u002FCanonicalSMILES\u002FJSON` returns 200), but the response JSON is keyed with the **new** names. So a request succeeds and only the parse step breaks with `KeyError`. Use `SMILES` \u002F `ConnectivitySMILES` in new code and read those keys.\n\n## Common Recipes\n\n### Recipe 1 — Lipinski's Rule of Five check\n\n```python\nimport requests\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndef check_lipinski(name):\n    cid = requests.get(f\"{BASE}\u002Fcompound\u002Fname\u002F{quote(name)}\u002Fcids\u002FJSON\"\n                       ).json()[\"IdentifierList\"][\"CID\"][0]\n    p = requests.get(\n        f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002Fproperty\u002F\"\n        \"MolecularWeight,XLogP,HBondDonorCount,HBondAcceptorCount\u002FJSON\"\n        ).json()[\"PropertyTable\"][\"Properties\"][0]\n    mw, xlogp = float(p[\"MolecularWeight\"]), p.get(\"XLogP\", 0) or 0\n    hbd, hba  = p[\"HBondDonorCount\"], p[\"HBondAcceptorCount\"]\n    rules = {\"MW ≤ 500\": mw \u003C= 500, \"XLogP ≤ 5\": xlogp \u003C= 5,\n             \"HBD ≤ 5\": hbd \u003C= 5,   \"HBA ≤ 10\": hba \u003C= 10}\n    v = sum(1 for ok in rules.values() if not ok)\n    return rules, v\n\nrules, v = check_lipinski(\"metformin\")\nprint(f\"violations: {v}\u002F4 ({'PASS' if v \u003C= 1 else 'FAIL'})\")\nfor r, ok in rules.items(): print(f\"  {'✓' if ok else '✗'} {r}\")\n```\n\n### Recipe 2 — Pull every synonym \u002F trade name\n\n```python\nimport requests\n\nr = requests.get(\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fname\u002Faspirin\u002Fsynonyms\u002FJSON\")\nsyns = r.json()[\"InformationList\"][\"Information\"][0][\"Synonym\"]\nprint(f\"{len(syns)} synonyms\")\nfor s in syns[:10]:\n    print(f\"  {s}\")\n```\n\n### Recipe 3 — Download a structure PNG\n\n```python\nimport requests\n\ncid = 2519   # caffeine\npng = requests.get(\n    f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG?image_size=large\"\n    ).content\nwith open(\"caffeine.png\", \"wb\") as f:\n    f.write(png)\nprint(f\"wrote caffeine.png ({len(png)} bytes)\")\n```\n\n### Recipe 4 — Robust session with retry \u002F 429 handling\n\n```python\nimport requests\nfrom requests.adapters import HTTPAdapter\nfrom urllib3.util.retry import Retry\n\ns = requests.Session()\ns.headers.update({\"Accept\": \"application\u002Fjson\"})\ns.mount(\"https:\u002F\u002F\", HTTPAdapter(max_retries=Retry(\n    total=4, backoff_factor=1.0,\n    status_forcelist=[429, 500, 502, 503, 504],\n    allowed_methods=[\"GET\", \"POST\"])))\n\nr = s.get(\n    \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F2244\u002Fproperty\u002FMolecularWeight\u002FJSON\",\n    timeout=15)\nr.raise_for_status()\nprint(r.json()[\"PropertyTable\"][\"Properties\"][0][\"MolecularWeight\"])\n```\n\n## Expected Outputs\n\n- **CID lookup** (`\u002F...\u002Fcids\u002FJSON`): `{\"IdentifierList\": {\"CID\": [...]}}` — list of integer CIDs, ordered by relevance for name searches.\n- **Properties** (`\u002F...\u002Fproperty\u002F...\u002FJSON`): `{\"PropertyTable\": {\"Properties\": [{\"CID\": ..., \"MolecularWeight\": \"180.16\", ...}, ...]}}`. One row per CID in input order; `MolecularWeight` is a *string*.\n- **Synonyms**: `{\"InformationList\": {\"Information\": [{\"CID\": 2244, \"Synonym\": [\"aspirin\", \"ACETYLSALICYLIC ACID\", \"50-78-2\", ...]}]}}`.\n- **Async search init**: HTTP 202 with `{\"Waiting\": {\"ListKey\": \"12345...\"}}`. Poll `\u002Fcompound\u002Flistkey\u002F{key}\u002Fcids\u002FJSON` until it returns `IdentifierList`.\n- **Assay summary**: `{\"Table\": {\"Columns\": {\"Column\": [...col names...]}, \"Row\": [{\"Cell\": [...]}, ...]}}`.\n- **SDF**: plain text starting with the CID header line; ends with `M  END` followed by SDF property blocks.\n- **PNG**: binary `image\u002Fpng`, ~2–4 KB at default size, ~10–20 KB at `image_size=large`.\n\n## Troubleshooting\n\n| Problem                                                                         | Cause                                                                              | Solution                                                                                                                            |\n| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |\n| HTTP 404 `PUGREST.NotFound`                                                     | Name \u002F SMILES \u002F formula matched no record                                          | Try a CAS number or InChIKey; check spelling in the PubChem web UI; canonical SMILES from RDKit often resolves where input SMILES doesn't |\n| HTTP 202 stuck in `{\"Waiting\":...}` for a similarity\u002Fsubstructure call           | Async job still running                                                            | Poll `\u002Fcompound\u002Flistkey\u002F{key}\u002Fcids\u002FJSON` every 2s up to ~30s; reduce `MaxRecords` if it never completes                              |\n| HTTP 503 `PUGREST.ServerBusy`                                                   | Tripped the 5-req\u002Fs or 400-req\u002Fmin rate limit                                      | Insert `time.sleep(0.25)` in loops; use the Retry session in Recipe 4; reduce concurrency                                            |\n| HTTP 400 on a SMILES URL                                                        | SMILES wasn't URL-encoded                                                          | Wrap in `urllib.parse.quote(smi, safe=\"\")` — `#`, `+`, `\u002F` and `\\` all break path parsing                                            |\n| `KeyError: 'CanonicalSMILES'` \u002F `KeyError: 'IsomericSMILES'`                    | Requested old name; URL returns 200 but 2025 JSON is keyed `ConnectivitySMILES` \u002F `SMILES` | Read `p[\"ConnectivitySMILES\"]` (connectivity, no stereo) or `p[\"SMILES\"]` (with stereo); update the property CSV to the new names    |\n| `TypeError: '>' not supported between instances of 'str' and 'int'`             | `MolecularWeight` is a string                                                      | `float(p[\"MolecularWeight\"])` before any arithmetic comparison                                                                       |\n| Batch `cid\u002F2244,3672,...` returns only some rows                                | URL exceeded server limit                                                          | Switch to `requests.post(url, data={\"cid\": \"2244,3672,...\"})`; same URL minus the value, body carries the CSV                        |\n| Empty `assaysummary` Table                                                      | CID has no bioassay records                                                        | Not all compounds are assayed; verify on the PubChem web page                                                                        |\n| `XLogP` is `None` for a valid CID                                               | Property not computed for that compound                                            | Guard with `p.get(\"XLogP\", 0) or 0` before arithmetic                                                                                |\n\n## Related Skills\n\n- `chembl-database-bioactivity` — IC50 \u002F Ki \u002F Kd target-binding data, deeper than PubChem's assay summaries\n- `rdkit-cheminformatics` — local SMILES\u002FMOL manipulation, fingerprints, descriptors, scaffold extraction\n- `pdb-database` — protein structures co-crystallized with the small molecules found via PubChem CIDs\n\n## References\n\n- [PubChem PUG-REST documentation](https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest) — Full URL grammar reference\n- [PUG-REST tutorial with worked examples](https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest-tutorial) — Step-by-step API walk-through\n- [PubChem property table](https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest#section=Compound-Property-Tables) — Authoritative list of `\u002Fproperty\u002F\u003Cname>` values and their semantics\n- [PubChem main site](https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002F) — Web interface for spot-checks\n- [Kim et al. (2023) Nucleic Acids Res — PubChem 2023 update](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fnar\u002Fgkac956)\n","# PubChem Compound Search\n\n## Overview\n\nPubChem (NCBI) is the largest freely available chemical database — 110M+ compounds, 280M+ substances, and millions of bioassay records. Its **PUG-REST JSON API** is the canonical programmatic surface, and every example here uses it directly via plain `requests`. The Python `pubchempy` wrapper is *not* required; the PUG-REST URL grammar is small enough that direct calls are more transparent, easier to retry\u002Fcache, and avoid sandbox dependency issues (the library is not in `TOOL_STATUS.md`).\n\nThe URL pattern is fixed and predictable:\n\n```\nhttps:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002F\u003Cinput>\u002F\u003Coperation>\u002F\u003Coutput>\n```\n\n- `\u003Cinput>`   = `compound\u002F{name,cid,smiles,inchikey,formula}\u002F\u003Cvalue>`\n- `\u003Coperation>` = `cids`, `property\u002F\u003Clist>`, `synonyms`, `description`, `assaysummary`, `JSON` (full record), `SDF`, `PNG`\n- `\u003Coutput>`  = `JSON`, `CSV`, `TXT`, `SDF`, `PNG`\n\nFor long-running operations (similarity, substructure, formula) the API returns HTTP 202 + `{\"Waiting\": {\"ListKey\": \"...\"}}`; poll `compound\u002Flistkey\u002F{key}\u002Fcids\u002FJSON` until it returns `IdentifierList`. The skill handles this pattern in Module 4.\n\n## When to Use\n\n- Looking up a compound by name, SMILES, InChIKey, or formula to get its PubChem CID\n- Retrieving molecular properties (molecular weight, XLogP, TPSA, H-bond donor\u002Facceptor counts, rotatable bonds, formula, IUPAC name) for one or many CIDs in a single request\n- Finding structurally similar compounds via Tanimoto similarity (async ListKey poll)\n- Searching for compounds containing a substructure \u002F pharmacophore motif\n- Fetching every synonym \u002F trade name \u002F CAS number for a CID\n- Pulling assay summary tables (active\u002Finactive screening results) for a compound\n- Converting between identifier formats (name ↔ CID ↔ SMILES ↔ InChI ↔ InChIKey) in one API call\n- Downloading 2D SDF or PNG structures for figures or downstream RDKit work\n- For local cheminformatics (fingerprints, descriptors, 3D conformers, scaffold extraction) use `rdkit`\n- For deeper bioactivity \u002F target-binding data (IC50, Ki against specific targets) use `chembl-database-bioactivity`\n\n## Prerequisites\n\n- **Python packages**: `requests`, `pandas` — both already in standard environments\n- **No API key required** — PubChem is fully public\n- **Rate limits**: max 5 requests\u002Fsecond and 400 requests\u002Fminute per IP. Throttle with `time.sleep(0.25)` in loops; return code 503 means you tripped the limit.\n\nIf you are inside a pixi\u002Fconda environment that already provides `requests` and `pandas`, skip the install and invoke scripts with `pixi run python ...`.\n\n```bash\npip install requests pandas\n```\n\n## Quick Start\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# name → CID\ncid = requests.get(f\"{BASE}\u002Fcompound\u002Fname\u002Faspirin\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"][0]\n\n# CID → properties (single call, many fields)\nr = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002Fproperty\u002F\"\n    \"MolecularWeight,XLogP,TPSA,HBondDonorCount,HBondAcceptorCount,SMILES,IUPACName\u002FJSON\")\np = r.json()[\"PropertyTable\"][\"Properties\"][0]\nprint(f\"CID {cid} — {p['IUPACName']}\")\nprint(f\"  MW={p['MolecularWeight']}  XLogP={p['XLogP']}  TPSA={p['TPSA']}\")\nprint(f\"  HBD={p['HBondDonorCount']}  HBA={p['HBondAcceptorCount']}\")\nprint(f\"  SMILES={p['SMILES']}\")\n```\n\n## Core API\n\n### Module 1: Identifier lookup\n\nResolve any external identifier to a PubChem CID via `\u002Fcompound\u002F{namespace}\u002F{value}\u002Fcids\u002FJSON`. Namespaces: `name`, `cid`, `smiles`, `inchikey`, `inchi`, `formula`.\n\n```python\nimport requests\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# By name (returns all matching CIDs as a list)\ncids = requests.get(f\"{BASE}\u002Fcompound\u002Fname\u002Fcaffeine\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"]\nprint(f\"caffeine CIDs: {cids}\")\n\n# By canonical SMILES (URL-encode!)\nsmi = quote(\"CC(=O)OC1=CC=CC=C1C(=O)O\", safe=\"\")\ncid = requests.get(f\"{BASE}\u002Fcompound\u002Fsmiles\u002F{smi}\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"][0]\nprint(f\"aspirin SMILES → CID {cid}\")\n\n# By InChIKey (exact match, fastest if you already have one)\nikey = \"BSYNRYMUTXBXSQ-UHFFFAOYSA-N\"\ncid = requests.get(f\"{BASE}\u002Fcompound\u002Finchikey\u002F{ikey}\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"][0]\nprint(f\"InChIKey → CID {cid}\")\n```\n\n### Module 2: Property retrieval\n\n`\u002Fcompound\u002Fcid\u002F{cid_or_csv}\u002Fproperty\u002F\u003Ccsv-list>\u002FJSON` returns all requested properties in one round trip. **CIDs and property names are both CSV-joinable** — batch up to ~200 CIDs and many properties at once.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# Full property set for a single compound (ibuprofen CID 3672)\nurl = (f\"{BASE}\u002Fcompound\u002Fcid\u002F3672\u002Fproperty\u002F\"\n       \"MolecularWeight,XLogP,TPSA,HBondDonorCount,HBondAcceptorCount,\"\n       \"RotatableBondCount,SMILES,InChIKey,IUPACName,MolecularFormula\u002FJSON\")\np = requests.get(url).json()[\"PropertyTable\"][\"Properties\"][0]\nprint(f\"{p['IUPACName']}  formula={p['MolecularFormula']}\")\nprint(f\"  MW={p['MolecularWeight']} XLogP={p['XLogP']} TPSA={p['TPSA']}\")\nprint(f\"  HBD={p['HBondDonorCount']} HBA={p['HBondAcceptorCount']} RotB={p['RotatableBondCount']}\")\n```\n\n```python\nimport requests, pandas as pd\n\n# Batch: 4 CIDs, 3 properties — one request, one round trip\ncids = \"2244,3672,2157,2662\"   # aspirin, ibuprofen, naproxen, celecoxib\nr = requests.get(\n    f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F{cids}\u002Fproperty\u002F\"\n    \"MolecularWeight,XLogP,TPSA\u002FJSON\")\ndf = pd.DataFrame(r.json()[\"PropertyTable\"][\"Properties\"])\nprint(df.to_string(index=False))\n```\n\n### Module 3: Synonyms and description\n\nSynonyms (trade names, CAS numbers, alternative spellings) and curated descriptions live at `\u002Fcompound\u002F{ns}\u002F{value}\u002F{synonyms|description}\u002FJSON`.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# Full synonym list (aspirin has ~700)\ninfo = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F2244\u002Fsynonyms\u002FJSON\").json()[\"InformationList\"][\"Information\"][0]\nprint(f\"aspirin synonyms: {len(info['Synonym'])}\")\nfor s in info[\"Synonym\"][:8]:\n    print(f\"  {s}\")\n```\n\n```python\nimport requests\n\n# Curated descriptions (NCBI MeSH, CAMEO, etc.)\nr = requests.get(\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fname\u002Faspirin\u002Fdescription\u002FJSON\")\nfor item in r.json()[\"InformationList\"][\"Information\"]:\n    if \"Description\" in item:\n        print(f\"[{item.get('DescriptionSourceName','?')}]\")\n        print(f\"  {item['Description'][:200]}…\")\n        print()\n```\n\n### Module 4: Similarity & substructure search (async ListKey pattern)\n\nStructure searches return HTTP 202 + `{\"Waiting\": {\"ListKey\": \"...\"}}`. Poll `\u002Fcompound\u002Flistkey\u002F{key}\u002Fcids\u002FJSON` every ~2s until it returns `IdentifierList`. Wrap this in a helper since it's used everywhere.\n\n```python\nimport requests, time\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndef poll_listkey(listkey, max_polls=10, interval=2.0):\n    \"\"\"Block until PubChem finishes async search; return CID list.\"\"\"\n    for _ in range(max_polls):\n        time.sleep(interval)\n        j = requests.get(f\"{BASE}\u002Fcompound\u002Flistkey\u002F{listkey}\u002Fcids\u002FJSON\", timeout=20).json()\n        if \"IdentifierList\" in j:\n            return j[\"IdentifierList\"][\"CID\"]\n    raise TimeoutError(f\"ListKey {listkey} did not complete\")\n\n# Tanimoto similarity (90% threshold, max 20 hits) — starting from aspirin SMILES\nsmi = quote(\"CC(=O)OC1=CC=CC=C1C(=O)O\", safe=\"\")\ninit = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fsimilarity\u002Fsmiles\u002F{smi}\u002FJSON?Threshold=90&MaxRecords=20\").json()\ncids = poll_listkey(init[\"Waiting\"][\"ListKey\"]) if \"Waiting\" in init \\\n       else init[\"IdentifierList\"][\"CID\"]\nprint(f\"aspirin @90% similarity: {len(cids)} hits, sample={cids[:5]}\")\n```\n\n```python\nimport requests\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\n# Substructure search — all compounds containing a sulfonamide group\nsmi = quote(\"S(=O)(=O)N\", safe=\"\")\ninit = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fsubstructure\u002Fsmiles\u002F{smi}\u002FJSON?MaxRecords=20\").json()\ncids = poll_listkey(init[\"Waiting\"][\"ListKey\"]) if \"Waiting\" in init \\\n       else init[\"IdentifierList\"][\"CID\"]\nprint(f\"sulfonamide-containing CIDs: {len(cids)}, sample={cids[:5]}\")\n```\n\n### Module 5: Assay summary (bioactivity data)\n\n`\u002Fcompound\u002Fcid\u002F{cid}\u002Fassaysummary\u002FJSON` returns a `Table` of every PubChem BioAssay the compound appears in (assay AID, target, outcome, micromolar activity if available).\n\n```python\nimport requests, pandas as pd\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\nr = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F2244\u002Fassaysummary\u002FJSON\", timeout=30)\nrows = r.json().get(\"Table\", {}).get(\"Row\", [])\ncols = r.json().get(\"Table\", {}).get(\"Columns\", {}).get(\"Column\", [])\nprint(f\"aspirin appears in {len(rows)} bioassays\")\n\n# First few columns + rows as a DataFrame\ndf = pd.DataFrame([row[\"Cell\"] for row in rows[:5]], columns=cols)\nprint(df.iloc[:, :6].to_string(index=False))\n```\n\n### Module 6: Structure file download (SDF \u002F PNG)\n\n`\u002Fcompound\u002Fcid\u002F{cid}\u002FSDF` returns 2D MOL\u002FSDF; `\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG` returns a structure image (use `?image_size=large` for higher resolution).\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\ncid = 2519   # caffeine\n\n# 2D SDF for downstream RDKit \u002F OpenBabel\nsdf = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002FSDF\", timeout=15).text\nwith open(\"caffeine.sdf\", \"w\") as f:\n    f.write(sdf)\nprint(f\"caffeine.sdf: {len(sdf)} chars, ends with M  END={'M  END' in sdf}\")\n\n# PNG structure image\npng = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG?image_size=large\", timeout=15).content\nwith open(\"caffeine.png\", \"wb\") as f:\n    f.write(png)\nprint(f\"caffeine.png: {len(png)} bytes\")\n```\n\n## Key Concepts\n\n### Async ListKey pattern\n\nSimilarity, substructure, and formula searches are **asynchronous** — the API kicks off a background job and returns HTTP 202 with `{\"Waiting\": {\"ListKey\": \"\u003Cid>\"}}`. Poll `\u002Fcompound\u002Flistkey\u002F{id}\u002Fcids\u002FJSON` every ~2 seconds until the response contains `IdentifierList`. Most searches finish in 5–15s; tighten polling for tiny searches, loosen for very large ones. Use the `poll_listkey` helper from Module 4 everywhere.\n\nA small fraction of fast searches return `IdentifierList` directly on the first call (no `Waiting` field); check for both possibilities.\n\n### Property name reference\n\n| API name              | Meaning                                   |\n| --------------------- | ----------------------------------------- |\n| `MolecularWeight`     | Molecular weight (g\u002Fmol, string)          |\n| `MolecularFormula`    | Hill-system formula                       |\n| `SMILES`              | Isomeric SMILES, with stereochemistry (2025+ name; was `IsomericSMILES`) |\n| `ConnectivitySMILES`  | Connectivity-only SMILES, no stereo (2025+ name; was `CanonicalSMILES`) |\n| `IUPACName`           | Curated IUPAC name                        |\n| `InChI` \u002F `InChIKey`  | IUPAC InChI \u002F InChIKey                    |\n| `XLogP`               | Computed logP (octanol\u002Fwater)             |\n| `TPSA`                | Topological polar surface area (Å²)       |\n| `HBondDonorCount`     | Number of H-bond donors                   |\n| `HBondAcceptorCount`  | Number of H-bond acceptors                |\n| `RotatableBondCount`  | Number of rotatable bonds                 |\n| `HeavyAtomCount`      | Non-hydrogen atom count                   |\n| `Charge`              | Formal charge                             |\n\nCSV-join any subset in a single `\u002Fproperty\u002F\u003Ccsv>\u002FJSON` URL. Note that `MolecularWeight` returns as a string; cast to `float` before arithmetic.\n\n### Response envelope shapes\n\n- `cids\u002FJSON`             → `{\"IdentifierList\": {\"CID\": [int, ...]}}`\n- `property\u002F...\u002FJSON`     → `{\"PropertyTable\": {\"Properties\": [{...}, ...]}}` (one dict per CID, in input order)\n- `synonyms\u002FJSON`         → `{\"InformationList\": {\"Information\": [{\"CID\": int, \"Synonym\": [str, ...]}]}}`\n- `description\u002FJSON`      → `{\"InformationList\": {\"Information\": [{\"CID\": int, \"Description\": str, \"DescriptionSourceName\": str, ...}, ...]}}`\n- `assaysummary\u002FJSON`     → `{\"Table\": {\"Columns\": {\"Column\": [...]}, \"Row\": [{\"Cell\": [...]}, ...]}}`\n- async-init (similarity, substructure, formula) → 202 with `{\"Waiting\": {\"ListKey\": \"...\"}}`\n- listkey poll            → `{\"IdentifierList\": {\"CID\": [...]}}` when ready\n\n## Common Workflows\n\n### Workflow 1: Property comparison across a drug panel\n\n**Goal**: side-by-side physicochemical comparison of a small molecule set.\n\n```python\nimport requests, pandas as pd, time\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndrugs = [\"aspirin\", \"ibuprofen\", \"naproxen\", \"celecoxib\"]\n\n# Resolve names → CIDs in a loop (rate-limited)\ncids = []\nfor d in drugs:\n    cid = requests.get(f\"{BASE}\u002Fcompound\u002Fname\u002F{quote(d)}\u002Fcids\u002FJSON\",\n                       timeout=15).json()[\"IdentifierList\"][\"CID\"][0]\n    cids.append(cid)\n    time.sleep(0.25)\n\n# Single batched property pull\ncid_csv = \",\".join(str(c) for c in cids)\nr = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid_csv}\u002Fproperty\u002F\"\n    \"MolecularWeight,XLogP,TPSA,HBondDonorCount,HBondAcceptorCount\u002FJSON\")\ndf = pd.DataFrame(r.json()[\"PropertyTable\"][\"Properties\"])\ndf[\"Name\"] = drugs\ndf = df[[\"Name\", \"CID\", \"MolecularWeight\", \"XLogP\", \"TPSA\",\n         \"HBondDonorCount\", \"HBondAcceptorCount\"]]\nprint(df.to_string(index=False))\n```\n\n### Workflow 2: Lead compound → similar analogs → properties\n\n**Goal**: starting from a kinase inhibitor (gefitinib), find 85%-similar analogs and pull their properties.\n\n```python\nimport requests, time\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndef poll_listkey(listkey, max_polls=10, interval=2.0):\n    for _ in range(max_polls):\n        time.sleep(interval)\n        j = requests.get(f\"{BASE}\u002Fcompound\u002Flistkey\u002F{listkey}\u002Fcids\u002FJSON\",\n                         timeout=20).json()\n        if \"IdentifierList\" in j:\n            return j[\"IdentifierList\"][\"CID\"]\n    raise TimeoutError(\"listkey timeout\")\n\n# 1. lead → CID → canonical SMILES\nref_cid = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fname\u002Fgefitinib\u002Fcids\u002FJSON\").json()[\"IdentifierList\"][\"CID\"][0]\nref_smi = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fcid\u002F{ref_cid}\u002Fproperty\u002FSMILES\u002FJSON\"\n    ).json()[\"PropertyTable\"][\"Properties\"][0][\"SMILES\"]\nprint(f\"gefitinib CID={ref_cid}  SMILES={ref_smi}\")\n\n# 2. similarity search\nsmi_q = quote(ref_smi, safe=\"\")\ninit = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fsimilarity\u002Fsmiles\u002F{smi_q}\u002FJSON?Threshold=85&MaxRecords=15\"\n    ).json()\nsim_cids = poll_listkey(init[\"Waiting\"][\"ListKey\"]) if \"Waiting\" in init \\\n           else init[\"IdentifierList\"][\"CID\"]\nprint(f\"  {len(sim_cids)} analogs @85% Tanimoto\")\n\n# 3. batch-pull properties for top 5 analogs\ncid_csv = \",\".join(str(c) for c in sim_cids[:5])\nr = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid_csv}\u002Fproperty\u002F\"\n    \"MolecularWeight,XLogP,TPSA,RotatableBondCount\u002FJSON\")\nfor row in r.json()[\"PropertyTable\"][\"Properties\"]:\n    print(f\"  CID {row['CID']}: MW={row['MolecularWeight']} XLogP={row['XLogP']}\")\n```\n\n### Workflow 3: Pharmacophore screen via substructure → bioactivity check\n\n**Goal**: find compounds with a sulfonamide motif and check which have bioactivity records.\n\n```python\nimport requests, time\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndef poll_listkey(listkey, max_polls=10, interval=2.0):\n    for _ in range(max_polls):\n        time.sleep(interval)\n        j = requests.get(f\"{BASE}\u002Fcompound\u002Flistkey\u002F{listkey}\u002Fcids\u002FJSON\",\n                         timeout=20).json()\n        if \"IdentifierList\" in j:\n            return j[\"IdentifierList\"][\"CID\"]\n    raise TimeoutError(\"listkey timeout\")\n\nsmi = quote(\"S(=O)(=O)N\", safe=\"\")\ninit = requests.get(\n    f\"{BASE}\u002Fcompound\u002Fsubstructure\u002Fsmiles\u002F{smi}\u002FJSON?MaxRecords=10\").json()\ncids = poll_listkey(init[\"Waiting\"][\"ListKey\"]) if \"Waiting\" in init \\\n       else init[\"IdentifierList\"][\"CID\"]\nprint(f\"sulfonamide CIDs: {cids}\")\n\n# Bioactivity row counts for the first few hits\nfor cid in cids[:3]:\n    rows = requests.get(f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002Fassaysummary\u002FJSON\",\n                        timeout=30).json().get(\"Table\", {}).get(\"Row\", [])\n    print(f\"  CID {cid}: {len(rows)} assay rows\")\n    time.sleep(0.3)\n```\n\n## Key Parameters\n\n| Parameter         | Endpoint \u002F Module                | Default | Range \u002F Options                            | Effect                                                                  |\n| ----------------- | -------------------------------- | ------- | ------------------------------------------ | ----------------------------------------------------------------------- |\n| `\u003Cnamespace>`     | `\u002Fcompound\u002F{ns}\u002F\u003Cvalue>\u002F...`     | —       | `name`, `cid`, `smiles`, `inchikey`, `inchi`, `formula` | Input identifier type                                                  |\n| `\u003Cproperty csv>`  | `\u002F...\u002Fproperty\u002F\u003Ccsv>\u002FJSON`       | —       | any subset of property names (see table)   | Which properties to return (one DB call per request)                    |\n| `Threshold`       | similarity (M4)                  | `90`    | `0`–`100`                                  | Tanimoto cutoff (percent)                                               |\n| `MaxRecords`      | similarity \u002F substructure \u002F formula | (server-side default) | `1`–`10000`                       | Cap on async result list                                                |\n| `image_size`      | `\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG`        | medium  | `small`, `large`, `WxH` (e.g. `500x500`)   | PNG output resolution                                                   |\n| `record_type`     | `\u002Fcompound\u002Fcid\u002F{cid}\u002FSDF`        | `2d`    | `2d`, `3d`                                 | SDF dimensionality (`?record_type=3d`)                                  |\n| `MaxAssayResults` | `\u002Fcompound\u002Fcid\u002F{cid}\u002Fassaysummary\u002FJSON` | —    | int                                        | Limit assay rows when compound has thousands of records                 |\n\n## Best Practices\n\n1. **Always go through `cids\u002FJSON` first** when starting from a name or external identifier. The name→CID resolution and the CID→property lookup are separate calls; doing both at once via `name → property` works but throws away the canonical CID list that downstream queries need.\n\n2. **Batch properties, never loop them.** `compound\u002Fcid\u002F2244,3672,2157,...\u002Fproperty\u002FMolecularWeight,XLogP,...\u002FJSON` accepts up to ~200 CIDs and any number of properties — one round trip instead of N. Looping `get_compounds` per name is the most common rate-limit trap.\n\n3. **URL-encode every SMILES.** Use `urllib.parse.quote(smiles, safe=\"\")`. Bare SMILES with `=`, `#`, `(`, `)`, `[`, `]` will sometimes work but breaks unpredictably on `+`, `\u002F`, `\\`, or query-string-looking substrings.\n\n4. **Treat similarity\u002Fsubstructure\u002Fformula as async.** Branch on `\"Waiting\" in response` and poll `listkey` rather than re-issuing the search. Re-issuing creates a new ListKey and wastes the server's job slot.\n\n5. **Throttle ≤ 5 req\u002Fsec, ≤ 400\u002Fmin.** Insert `time.sleep(0.25)` in any tight loop. HTTP 503 means you tripped the limit — wait 10s and reduce concurrency.\n\n6. **Cast `MolecularWeight` to `float`.** It's returned as a string (`\"180.16\"`) for full decimal fidelity. Comparing strings against numeric thresholds is a silent bug.\n\n7. **For 100+ CIDs use POST.** GET URLs over ~2000 chars get truncated by some HTTP proxies. PubChem also accepts `POST` with `cid` in the form body: `requests.post(f\"{BASE}\u002Fcompound\u002Fcid\u002Fproperty\u002FMolecularWeight\u002FJSON\", data={\"cid\": cid_csv})`.\n\n8. **2025 SMILES property rename.** PubChem renamed two SMILES properties in the 2025 PUG-REST schema: old `IsomericSMILES` (with stereo) → `SMILES`, and old `CanonicalSMILES` (connectivity only, no stereo) → `ConnectivitySMILES`. The URL path still accepts the legacy names as *input* (e.g. `\u002Fproperty\u002FCanonicalSMILES\u002FJSON` returns 200), but the response JSON is keyed with the **new** names. So a request succeeds and only the parse step breaks with `KeyError`. Use `SMILES` \u002F `ConnectivitySMILES` in new code and read those keys.\n\n## Common Recipes\n\n### Recipe 1 — Lipinski's Rule of Five check\n\n```python\nimport requests\nfrom urllib.parse import quote\n\nBASE = \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\"\n\ndef check_lipinski(name):\n    cid = requests.get(f\"{BASE}\u002Fcompound\u002Fname\u002F{quote(name)}\u002Fcids\u002FJSON\"\n                       ).json()[\"IdentifierList\"][\"CID\"][0]\n    p = requests.get(\n        f\"{BASE}\u002Fcompound\u002Fcid\u002F{cid}\u002Fproperty\u002F\"\n        \"MolecularWeight,XLogP,HBondDonorCount,HBondAcceptorCount\u002FJSON\"\n        ).json()[\"PropertyTable\"][\"Properties\"][0]\n    mw, xlogp = float(p[\"MolecularWeight\"]), p.get(\"XLogP\", 0) or 0\n    hbd, hba  = p[\"HBondDonorCount\"], p[\"HBondAcceptorCount\"]\n    rules = {\"MW ≤ 500\": mw \u003C= 500, \"XLogP ≤ 5\": xlogp \u003C= 5,\n             \"HBD ≤ 5\": hbd \u003C= 5,   \"HBA ≤ 10\": hba \u003C= 10}\n    v = sum(1 for ok in rules.values() if not ok)\n    return rules, v\n\nrules, v = check_lipinski(\"metformin\")\nprint(f\"violations: {v}\u002F4 ({'PASS' if v \u003C= 1 else 'FAIL'})\")\nfor r, ok in rules.items(): print(f\"  {'✓' if ok else '✗'} {r}\")\n```\n\n### Recipe 2 — Pull every synonym \u002F trade name\n\n```python\nimport requests\n\nr = requests.get(\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fname\u002Faspirin\u002Fsynonyms\u002FJSON\")\nsyns = r.json()[\"InformationList\"][\"Information\"][0][\"Synonym\"]\nprint(f\"{len(syns)} synonyms\")\nfor s in syns[:10]:\n    print(f\"  {s}\")\n```\n\n### Recipe 3 — Download a structure PNG\n\n```python\nimport requests\n\ncid = 2519   # caffeine\npng = requests.get(\n    f\"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F{cid}\u002FPNG?image_size=large\"\n    ).content\nwith open(\"caffeine.png\", \"wb\") as f:\n    f.write(png)\nprint(f\"wrote caffeine.png ({len(png)} bytes)\")\n```\n\n### Recipe 4 — Robust session with retry \u002F 429 handling\n\n```python\nimport requests\nfrom requests.adapters import HTTPAdapter\nfrom urllib3.util.retry import Retry\n\ns = requests.Session()\ns.headers.update({\"Accept\": \"application\u002Fjson\"})\ns.mount(\"https:\u002F\u002F\", HTTPAdapter(max_retries=Retry(\n    total=4, backoff_factor=1.0,\n    status_forcelist=[429, 500, 502, 503, 504],\n    allowed_methods=[\"GET\", \"POST\"])))\n\nr = s.get(\n    \"https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fcid\u002F2244\u002Fproperty\u002FMolecularWeight\u002FJSON\",\n    timeout=15)\nr.raise_for_status()\nprint(r.json()[\"PropertyTable\"][\"Properties\"][0][\"MolecularWeight\"])\n```\n\n## Expected Outputs\n\n- **CID lookup** (`\u002F...\u002Fcids\u002FJSON`): `{\"IdentifierList\": {\"CID\": [...]}}` — list of integer CIDs, ordered by relevance for name searches.\n- **Properties** (`\u002F...\u002Fproperty\u002F...\u002FJSON`): `{\"PropertyTable\": {\"Properties\": [{\"CID\": ..., \"MolecularWeight\": \"180.16\", ...}, ...]}}`. One row per CID in input order; `MolecularWeight` is a *string*.\n- **Synonyms**: `{\"InformationList\": {\"Information\": [{\"CID\": 2244, \"Synonym\": [\"aspirin\", \"ACETYLSALICYLIC ACID\", \"50-78-2\", ...]}]}}`.\n- **Async search init**: HTTP 202 with `{\"Waiting\": {\"ListKey\": \"12345...\"}}`. Poll `\u002Fcompound\u002Flistkey\u002F{key}\u002Fcids\u002FJSON` until it returns `IdentifierList`.\n- **Assay summary**: `{\"Table\": {\"Columns\": {\"Column\": [...col names...]}, \"Row\": [{\"Cell\": [...]}, ...]}}`.\n- **SDF**: plain text starting with the CID header line; ends with `M  END` followed by SDF property blocks.\n- **PNG**: binary `image\u002Fpng`, ~2–4 KB at default size, ~10–20 KB at `image_size=large`.\n\n## Troubleshooting\n\n| Problem                                                                         | Cause                                                                              | Solution                                                                                                                            |\n| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |\n| HTTP 404 `PUGREST.NotFound`                                                     | Name \u002F SMILES \u002F formula matched no record                                          | Try a CAS number or InChIKey; check spelling in the PubChem web UI; canonical SMILES from RDKit often resolves where input SMILES doesn't |\n| HTTP 202 stuck in `{\"Waiting\":...}` for a similarity\u002Fsubstructure call           | Async job still running                                                            | Poll `\u002Fcompound\u002Flistkey\u002F{key}\u002Fcids\u002FJSON` every 2s up to ~30s; reduce `MaxRecords` if it never completes                              |\n| HTTP 503 `PUGREST.ServerBusy`                                                   | Tripped the 5-req\u002Fs or 400-req\u002Fmin rate limit                                      | Insert `time.sleep(0.25)` in loops; use the Retry session in Recipe 4; reduce concurrency                                            |\n| HTTP 400 on a SMILES URL                                                        | SMILES wasn't URL-encoded                                                          | Wrap in `urllib.parse.quote(smi, safe=\"\")` — `#`, `+`, `\u002F` and `\\` all break path parsing                                            |\n| `KeyError: 'CanonicalSMILES'` \u002F `KeyError: 'IsomericSMILES'`                    | Requested old name; URL returns 200 but 2025 JSON is keyed `ConnectivitySMILES` \u002F `SMILES` | Read `p[\"ConnectivitySMILES\"]` (connectivity, no stereo) or `p[\"SMILES\"]` (with stereo); update the property CSV to the new names    |\n| `TypeError: '>' not supported between instances of 'str' and 'int'`             | `MolecularWeight` is a string                                                      | `float(p[\"MolecularWeight\"])` before any arithmetic comparison                                                                       |\n| Batch `cid\u002F2244,3672,...` returns only some rows                                | URL exceeded server limit                                                          | Switch to `requests.post(url, data={\"cid\": \"2244,3672,...\"})`; same URL minus the value, body carries the CSV                        |\n| Empty `assaysummary` Table                                                      | CID has no bioassay records                                                        | Not all compounds are assayed; verify on the PubChem web page                                                                        |\n| `XLogP` is `None` for a valid CID                                               | Property not computed for that compound                                            | Guard with `p.get(\"XLogP\", 0) or 0` before arithmetic                                                                                |\n\n## Related Skills\n\n- `chembl-database-bioactivity` — IC50 \u002F Ki \u002F Kd target-binding data, deeper than PubChem's assay summaries\n- `rdkit-cheminformatics` — local SMILES\u002FMOL manipulation, fingerprints, descriptors, scaffold extraction\n- `pdb-database` — protein structures co-crystallized with the small molecules found via PubChem CIDs\n\n## References\n\n- [PubChem PUG-REST documentation](https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest) — Full URL grammar reference\n- [PUG-REST tutorial with worked examples](https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest-tutorial) — Step-by-step API walk-through\n- [PubChem property table](https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fdocs\u002Fpug-rest#section=Compound-Property-Tables) — Authoritative list of `\u002Fproperty\u002F\u003Cname>` values and their semantics\n- [PubChem main site](https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002F) — Web interface for spot-checks\n- [Kim et al. (2023) Nucleic Acids Res — PubChem 2023 update](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fnar\u002Fgkac956)\n",{"name":5,"license":15,"metadata":24,"description":7},{"quick_use":25},"one compound: GET https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Frest\u002Fpug\u002Fcompound\u002Fname\u002F{name}\u002Fproperty\u002FSMILES,ConnectivitySMILES,MolecularFormula,MolecularWeight,IUPACName\u002FJSON (or compound\u002Fcid\u002F{CID}\u002F...) -> r.json()['PropertyTable']['Properties'][0]. Response keys are `SMILES` (isomeric) and `ConnectivitySMILES`; `CanonicalSMILES`\u002F`IsomericSMILES` never come back, even when requested. Unknown name -> 404 (PUGREST.NotFound). 2D image: ...\u002Fcompound\u002Fname\u002F{name}\u002FPNG. Cite https:\u002F\u002Fpubchem.ncbi.nlm.nih.gov\u002Fcompound\u002F{CID}","master","fd76f882a04e445e899d5cfb2732f2105ea054ee","skills\u002Fawesome-skills\u002Fpubchem-compound-search",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill pubchem-compound-search",{"tool":42,"command":43},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill pubchem-compound-search",{"tool":45,"command":46},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill pubchem-compound-search","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fpubchem-compound-search\u002FSKILL.md",true,[],[51,60,67,74,81,88],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":59},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":59},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":59},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":59},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":59},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":55,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":59},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]