Simplify the retrieval of information from PubChem using the PubChem JSON API.
$ npm i pubchem
import { Compound } from 'pubchem';
async function doAll() {
const compound = await Compound.fromSmiles('CCCCCBr', { cache });
console.log(compound.getCID());
const compoundData = await compound.getData();
const ghs = compoundData.ghs;
console.log(ghs);
const detailedGHS = compoundData.getGHS();
console.log(detailedGHS);
const computed = compoundData.computed;
console.log(computed);
const experimentalData = compoundData.getExperimentalData({
pressure: { targetUnits: 'torr' },
temperature: { targetUnits: '°C' },
});
console.log(experimentalData);
}
doAll();
You can run a working example using:
node test/simple.js