Read from the package's own PHP files at the commit 2220782f98a6: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.
PubChemSourceclassPubChem (pubchem.ncbi.nlm.nih.gov), through PUG-REST: a compound by its CID, a name, an InChIKey, an InChI, a CAS number, a SMILES, or an identifier of another base that PubChem keeps among its synonyms (ChEBI, ChEMBL, Wikidata, UNII, DSSTox); its computed properties with their units, its synonyms, its description (from the depositor PubChem names), the image of its 2D structure, and its identifiers in other bases.
5 methods · 2 constants
PubChemSourceFactoryclassPubChem: compounds, their computed properties, synonyms, structure and cross-references - no key needed.
4 options
Omnilab\PubChem
PubChemSource class
final class PubChemSource extends HttpSource PubChemSource.php:33
PubChem (pubchem.ncbi.nlm.nih.gov), through PUG-REST: a compound by its CID, a name, an InChIKey, an InChI, a CAS number, a SMILES, or an identifier of another base that PubChem keeps among its synonyms (ChEBI, ChEMBL, Wikidata, UNII, DSSTox); its computed properties with their units, its synonyms, its description (from the depositor PubChem names), the image of its 2D structure, and its identifiers in other bases.
No key. PubChem asks for at most five calls a second and 400 a minute: the source leaves 0.2 s between two calls (the "throttle" option), and a compound costs up to four (its CID, properties, synonyms, description). A 503 ("server busy") is an UnavailableException.
const BASE_URI = 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/'const MAX_PER_PAGE = 100The most CIDs one property call is asked for.
PubChemSource::__construct()
public function __construct(HttpClientInterface $http, readonly int $synonyms = 20, readonly bool $description = true, string $baseUri = self::BASE_URI, array $headers = [], float $throttle = 0.2)$synonymshow many synonyms to keep (0: none, and no call for them)
$descriptionwhether to read the description (one call)
PubChemSource::getName()
public function getName(): stringPubChemSource::capabilities()
public function capabilities(): arrayPubChemSource::entity()
public function entity(Identifier|string $id): ?EntityPubChemSource::search()
public function search(Query $query): PageCompounds named by the text: those whose name is the text first, then those with a name that holds it as a word (PubChem's name_type=word), each once; read with a few properties only - entity() reads the rest.
PubChemSourceFactory class
final class PubChemSourceFactory extends SourceFactory PubChemSourceFactory.php:21
PubChem: compounds, their computed properties, synonyms, structure and cross-references - no key needed.
options: mailto: 'support@glitchr.io' # in the User-Agent: whom NCBI writes to before it blocks a caller synonyms: 20 # how many synonyms to keep (0: none, one call less per compound) description: true # false: no description, one call less per compound throttle: 0.2 # seconds between two calls: PubChem allows five a second, never set it lower base_uri: 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/'
Options
| Option | Default | |
|---|---|---|
synonyms | 20 | |
description | true | |
throttle | 0.2 | |
base_uri | PubChemSource::BASE_URI |