How to hit the PubChem API

PubChem's PUG REST API at https://pubchem.ncbi.nlm.nih.gov/rest/pug looks compounds up by name, id, or structure. The URL reads left to right: input, operation, output format.

Authentication

None. Keep to about 5 requests a second.

Full reference: https://pubchem.ncbi.nlm.nih.gov/docs/pug-rest

Compound properties by name

curl https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/caffeine/property/MolecularFormula,MolecularWeight,IUPACName/JSON
Run in PostTaco
Example response (trimmed)
{
  "PropertyTable": {
    "Properties": [
      {
        "CID": 2519,
        "MolecularFormula": "C8H10N4O2",
        "MolecularWeight": "194.19",
        "IUPACName": "1,3,7-trimethylpurine-2,6-dione"
      }
    ]
  }
}

Other names for a compound

curl https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/aspirin/synonyms/JSON
Run in PostTaco
Example response (trimmed)
{
  "InformationList": {
    "Information": [
      {
        "CID": 2244,
        "Synonym": [
          "aspirin",
          "ACETYLSALICYLIC ACID"
        ]
      }
    ]
  }
}