# Is there a Python package to convert InChi to molecular structures?

I am looking for a python package that can convert InChi keys (e.g.SGNXVBOIDPPRJJ-UHFFFAOYSA-N) to molecular structure or SMILES strings. Can I do that with RDKit?

The key comes from: https://www.metabolomicsworkbench.org/databases/refmet/refmet_latest.txt

Yes, RDKit can be used, however, if you installed it with conda it will not work out of the box for inChi key fetching. You can either spend some time installing the missing bit or use something else. It is not like Mol2 support in RDKit, which shouldn't be used, it is just not worth the bother.

I would suggest PubChem's RESTFul API.

Say

 import requests
ethanol = 'LFQSCWFLJHTTHZ-UHFFFAOYSA-N'
r = requests.get(f'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchikey/{ethanol}/property/CanonicalSMILES/JSON').json()
smiles = r['PropertyTable']['Properties'][0]['CanonicalSMILES']

• Hey, thanks for the answer. Though I get {'Fault': {'Code': 'PUGREST.BadRequest', 'Message': 'Missing structure string', 'Details': ["An argument for 'inchi' must be provided in the URL path or POST data"]}} when I run your code. Nov 19 '19 at 23:56
• Sorry for that. I fixed the typo by using your code. But I am glad it works now! Nov 20 '19 at 8:45

import requests