# PubChem Compound Scraper — Chemical Properties & SMILES (`compute-edge/pubchem-compound-scraper`) Actor

Fetch molecular formula, weight, SMILES, InChIKey, XLogP, TPSA, and more for any compound from PubChem — the world's largest free chemistry database.

- **URL**: https://apify.com/compute-edge/pubchem-compound-scraper.md
- **Developed by:** [Compute Edge](https://apify.com/compute-edge) (community)
- **Categories:** Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## PubChem Compound Scraper — Chemical Properties & SMILES

Extract structured chemical compound data from **PubChem**, the world's largest freely accessible chemistry database maintained by the NIH/NCBI. With over **115 million compounds** and growing, PubChem is the authoritative source for molecular properties used in drug discovery, cheminformatics, and computational chemistry.

This Actor calls PubChem's official **PUG-REST API** — no authentication required — and returns structured JSON for every compound: molecular formula, SMILES notation, InChIKey, drug-likeness metrics (XLogP, TPSA, Lipinski rule-of-five parameters), and more.

### Features

- **Look up by name or CID** — search by IUPAC name, common name, brand name, or PubChem Compound ID
- **30-compound default run** — aspirin, caffeine, glucose, and 27 other common compounds out of the box with zero configuration
- **Drug-likeness metrics** — XLogP, TPSA, H-bond donor/acceptor counts, and rotatable bond count for Lipinski filtering
- **SMILES & InChIKey** — canonical SMILES and InChIKey for cheminformatics pipelines and database lookups
- **Batch input** — supply hundreds of names or CIDs via a simple list
- **Rate-limit aware** — automatic 250ms delay between requests respects PubChem's rate limits; 503 errors trigger a 1-second retry
- **LLM-ready output** — clean, structured JSON ideal for RAG pipelines and AI/ML workflows

### Data Fields

| Field | Type | Description |
|-------|------|-------------|
| `cid` | number | PubChem Compound ID |
| `inputName` | string | Query term used for name lookups (null for CID lookups) |
| `molecularFormula` | string | Molecular formula (e.g. `C9H8O4`) |
| `molecularWeight` | number | Molecular weight in g/mol |
| `iupacName` | string | Systematic IUPAC name |
| `smiles` | string | SMILES notation (ConnectivitySMILES preferred, CanonicalSMILES fallback) |
| `inchiKey` | string | InChIKey hash for structure identification |
| `xlogP` | number | Predicted partition coefficient (lipophilicity) |
| `tpsa` | number | Topological polar surface area (Å²) |
| `hBondDonorCount` | number | Number of hydrogen bond donors |
| `hBondAcceptorCount` | number | Number of hydrogen bond acceptors |
| `rotatableBondCount` | number | Number of rotatable bonds |
| `exactMass` | number | Exact monoisotopic mass |
| `charge` | number | Net formal charge |
| `pubchemUrl` | string | Link to the compound's PubChem page |

### How to Scrape PubChem Compound Data

1. **Open the Actor** on the Apify platform and click **Try for free**.
2. **Leave inputs empty** to run with the built-in default list of 30 common compounds (aspirin, caffeine, glucose, etc.), or provide your own list.
3. **Enter compound names** in the "Compound Names" field — one per line (e.g. `warfarin`, `metformin`, `sertraline`).
4. **Or enter CIDs** in the "PubChem CIDs" field for direct lookups (e.g. `2244` for aspirin, `5090` for caffeine). You can mix names and CIDs.
5. **Set Max Results** to cap the number of compounds returned (default: 1000).
6. **Click Start** and results appear in the Dataset tab — typically within seconds for small lists.
7. **Export** as JSON, CSV, or Excel, or connect via the Apify API for downstream processing.

### Input Example

```json
{
  "names": ["metformin", "atorvastatin", "lisinopril", "omeprazole"],
  "cids": ["2244", "5090"],
  "maxResults": 100
}
````

### Output Example

```json
{
  "cid": 2244,
  "inputName": "aspirin",
  "molecularFormula": "C9H8O4",
  "molecularWeight": 180.16,
  "iupacName": "2-acetyloxybenzoic acid",
  "smiles": "CC(=O)Oc1ccccc1C(=O)O",
  "inchiKey": "BSYNRYMUTXBXSQ-UHFFFAOYSA-N",
  "xlogP": 1.2,
  "tpsa": 63.6,
  "hBondDonorCount": 1,
  "hBondAcceptorCount": 4,
  "rotatableBondCount": 3,
  "exactMass": 180.042259,
  "charge": 0,
  "pubchemUrl": "https://pubchem.ncbi.nlm.nih.gov/compound/2244"
}
```

### Use Cases

- **Cheminformatics & Drug Discovery** — Build compound libraries, run Lipinski rule-of-five screening, generate SMILES datasets for machine learning models
- **Chemical Supplier Research** — Cross-reference product catalogs with PubChem data to validate molecular identity
- **RAG Datasets & LLM Training** — Generate clean, structured chemistry corpora for AI models and retrieval-augmented generation pipelines
- **Research & Academia** — Automate literature review data collection, compare compound properties across series
- **Regulatory & Compliance** — Look up InChIKeys for compound identity verification in pharmaceutical submissions

### FAQ

**Q: Does this require an API key?**
A: No. PubChem's PUG-REST API is completely free and open — no registration or authentication required.

**Q: How many compounds can I fetch?**
A: The Actor supports up to 50,000 compounds per run. PubChem itself has 115M+ compounds. For large runs, the built-in 250ms delay keeps you within PubChem's rate limits (~5 req/sec).

**Q: What if a compound name isn't found?**
A: The Actor logs a warning and skips it, continuing with the rest of the list. Common causes: misspellings, ambiguous names, or brand names not indexed in PubChem. Try the IUPAC name or CID for reliable lookups.

**Q: Can I look up by InChIKey or SMILES?**
A: The current version supports lookup by name and CID. InChIKey and SMILES lookup can be added — contact the author or open an issue if needed.

### Other Actors

- **FDA OpenFDA Scraper** — Extract drug labels, indications, and adverse events from FDA OpenFDA
- **DailyMed Drug Database Scraper** — Structured prescription drug label data from NIH DailyMed
- **ClinicalTrials.gov Scraper** — Active and completed clinical trial data including endpoints and enrollment

### Legal Disclaimer

This Actor uses PubChem's official PUG-REST API, which is explicitly provided for programmatic access by the NIH/NCBI. All data is in the public domain. This Actor is provided for research and informational purposes. The author is not affiliated with PubChem, NIH, or NCBI. Always verify compound data from primary sources before use in any application affecting human health or safety. For questions or support, contact the actor author through the Apify platform.

# Actor input Schema

## `names` (type: `array`):

List of compound names to look up (e.g. aspirin, caffeine). Leave empty to use the built-in default list of 30 common compounds.

## `cids` (type: `array`):

List of PubChem Compound IDs (CIDs) to look up (e.g. 2244 for aspirin). Can be mixed with names.

## `maxResults` (type: `integer`):

Maximum number of compounds to fetch.

## Actor input object example

```json
{
  "names": [
    "aspirin",
    "caffeine",
    "ibuprofen",
    "acetaminophen",
    "glucose"
  ],
  "cids": [],
  "maxResults": 1000
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "names": [
        "aspirin",
        "caffeine",
        "ibuprofen",
        "acetaminophen",
        "glucose"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("compute-edge/pubchem-compound-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "names": [
        "aspirin",
        "caffeine",
        "ibuprofen",
        "acetaminophen",
        "glucose",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("compute-edge/pubchem-compound-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "names": [
    "aspirin",
    "caffeine",
    "ibuprofen",
    "acetaminophen",
    "glucose"
  ]
}' |
apify call compute-edge/pubchem-compound-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=compute-edge/pubchem-compound-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "PubChem Compound Scraper — Chemical Properties & SMILES",
        "description": "Fetch molecular formula, weight, SMILES, InChIKey, XLogP, TPSA, and more for any compound from PubChem — the world's largest free chemistry database.",
        "version": "0.1",
        "x-build-id": "sMQ8kEv6g3g0D3RcC"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/compute-edge~pubchem-compound-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-compute-edge-pubchem-compound-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/compute-edge~pubchem-compound-scraper/runs": {
            "post": {
                "operationId": "runs-sync-compute-edge-pubchem-compound-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/compute-edge~pubchem-compound-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-compute-edge-pubchem-compound-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "names": {
                        "title": "Compound Names",
                        "type": "array",
                        "description": "List of compound names to look up (e.g. aspirin, caffeine). Leave empty to use the built-in default list of 30 common compounds.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "cids": {
                        "title": "PubChem CIDs",
                        "type": "array",
                        "description": "List of PubChem Compound IDs (CIDs) to look up (e.g. 2244 for aspirin). Can be mixed with names.",
                        "default": [],
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 1,
                        "maximum": 50000,
                        "type": "integer",
                        "description": "Maximum number of compounds to fetch.",
                        "default": 1000
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
