molshape / ChemFormula

ChemFormula is a Python class for working with chemical formulas. It allows parsing chemical formulas, calculating formula weights for stoichiometric calculations, and generating formatted output strings (e.g. HTML).
https://pypi.org/project/ChemFormula/
MIT License
24 stars 2 forks source link

Get formula #13

Closed RedStone45789 closed 1 year ago

RedStone45789 commented 1 year ago

I am currently building a discord bot that can tell you the formula of a chemical by CAS number, can someone help me?

molshape commented 1 year ago

You cannot infer the chemical formula from a CAS Registry Number. In order to obtain the chemical formula behind a CAS number by entering it, a database query must be made. CAS offers its own API for this purpose: CAS API, but their database is not freely accessible. There are other webservices that allow CAS RN search like ChemSrc, but I think that they don't offer a freely accessible API either.