Forge Tools pubchem_compound

pubchem_compound read

scidex.forge.pubchem_compound

Query PubChem (100M+ compounds) by name, SMILES, or CID. Returns compound properties: molecular formula, molecular weight, canonical SMILES, InChIKey, XLogP, H-bond counts, and optionally active bioassay count. Free REST API — no API key required; set NCBI_API_KEY for higher rate limits (10 req/s vs 5 req/s).

HTTP: POST /api/scidex/forge/pubchem_compound

Invoke

Calls scidex.tool.invoke on the substrate with this tool name. Edit the JSON below — it must match the input schema. The substrate runs the tool, records the call in substrate_tool_calls, and returns a structured envelope.

Sign in to invoke this tool. Schema and curl snippet are visible to anyone.

Schemas

Input schema
{
  "additionalProperties": false,
  "description": "Input schema for ``scidex.forge.pubchem_compound``.",
  "properties": {
    "compound_name": {
      "anyOf": [
        {
          "maxLength": 300,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Chemical name, IUPAC name, or trade name (e.g. ``aspirin``, ``2-(acetyloxy)benzoic acid``). At least one of compound_name / smiles / cid is required.",
      "title": "Compound Name"
    },
    "smiles": {
      "anyOf": [
        {
          "maxLength": 1000,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "SMILES string for structure-based lookup (e.g. ``CC(=O)Oc1ccccc1C(=O)O`` for aspirin).",
      "title": "Smiles"
    },
    "cid": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "PubChem CID for direct lookup (e.g. ``2244`` for aspirin).",
      "title": "Cid"
    },
    "include_bioassays": {
      "default": false,
      "description": "When True, fetch the active bioassay count for each compound. Adds one HTTP request per compound.",
      "title": "Include Bioassays",
      "type": "boolean"
    },
    "limit": {
      "default": 10,
      "description": "Maximum number of compounds to return (default 10, max 100).",
      "maximum": 100,
      "minimum": 1,
      "title": "Limit",
      "type": "integer"
    }
  },
  "title": "ForgePubChemIn",
  "type": "object"
}
Output schema
{
  "$defs": {
    "PubChemCompound": {
      "description": "One PubChem compound record in the response.",
      "properties": {
        "cid": {
          "description": "PubChem Compound ID.",
          "title": "Cid",
          "type": "integer"
        },
        "iupac_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "IUPAC systematic name.",
          "title": "Iupac Name"
        },
        "molecular_formula": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Molecular formula (e.g. ``C9H8O4``).",
          "title": "Molecular Formula"
        },
        "molecular_weight": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Molecular weight in g/mol.",
          "title": "Molecular Weight"
        },
        "canonical_smiles": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Canonical SMILES string.",
          "title": "Canonical Smiles"
        },
        "inchikey": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "InChIKey (27-character hash of InChI).",
          "title": "Inchikey"
        },
        "xlogp": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Computed XLogP water-octanol partition coefficient.",
          "title": "Xlogp"
        },
        "h_bond_donor_count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Number of hydrogen bond donors.",
          "title": "H Bond Donor Count"
        },
        "h_bond_acceptor_count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Number of hydrogen bond acceptors.",
          "title": "H Bond Acceptor Count"
        },
        "active_bioassay_count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Number of PubChem bioassays where this compound was active. Populated only when ``include_bioassays=True``.",
          "title": "Active Bioassay Count"
        },
        "pubchem_url": {
          "description": "Direct link to this compound's PubChem page.",
          "title": "Pubchem Url",
          "type": "string"
        }
      },
      "required": [
        "cid",
        "pubchem_url"
      ],
      "title": "PubChemCompound",
      "type": "object"
    }
  },
  "description": "Response shape for ``scidex.forge.pubchem_compound``.",
  "properties": {
    "compounds": {
      "description": "Matching PubChem compounds.",
      "items": {
        "$ref": "#/$defs/PubChemCompound"
      },
      "title": "Compounds",
      "type": "array"
    },
    "total_found": {
      "default": 0,
      "description": "Total compounds found before the ``limit`` was applied. May exceed ``len(compounds)``.",
      "title": "Total Found",
      "type": "integer"
    },
    "took_ms": {
      "description": "Wall-clock time for the upstream calls.",
      "title": "Took Ms",
      "type": "integer"
    }
  },
  "required": [
    "took_ms"
  ],
  "title": "ForgePubChemOut",
  "type": "object"
}

curl snippet

Replace $SCIDEX_JWT with a valid bearer token. Read verbs are usually accessible without auth in dev; production requires a JWT.

curl -sS -X POST '/api/scidex/forge/pubchem_compound' \
  -H 'authorization: Bearer $SCIDEX_JWT' \
  -H 'content-type: application/json' \
  -d '{}'

Discussion

Posting anonymously. Sign in for attribution.

No comments yet — be the first.