Skip to content

omnilab/pubchem API reference

Floor
Provider · Omnilab
Version
1.x
Conformance suite
not wired
Verified for real
Its README does not say
Licence
MIT
composer require omnilab/pubchem:1.x-dev

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.

Omnilab\PubChem

  • PubChemSource class

    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.

    5 methods · 2 constants

  • PubChemSourceFactory class

    PubChem: 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 = 100

The 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)
$synonyms

how many synonyms to keep (0: none, and no call for them)

$description

whether to read the description (one call)

PubChemSource::getName()

public function getName(): string

PubChemSource::capabilities()

public function capabilities(): array

PubChemSource::entity()

public function entity(Identifier|string $id): ?Entity
public function search(Query $query): Page

Compounds 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

OptionDefault
synonyms20
descriptiontrue
throttle0.2
base_uriPubChemSource::BASE_URI