<jupyter_start><jupyter_text>ChemSpiPy: Getting StartedBefore we start:- Make sure you have [installed ChemSpiPy](http://chemspipy.readthedocs.io/en/latest/guide/install.htmlinstall).- [Obtain a security token](http://chemspipy.readthedocs.io/en/latest/guide/intro.htmlsecuritytoken) from the ChemSpider web site. First StepsStart by importing ChemSpider:<jupyter_code>from chemspipy import ChemSpider<jupyter_output><empty_output><jupyter_text>Then connect to ChemSpider by creating a ChemSpider instance using your security token:<jupyter_code># Tip: Store your security token as an environment variable to reduce the chance of accidentally sharing it
import os
mytoken = os.environ['CHEMSPIDER_SECURITY_TOKEN']

cs = ChemSpider(security_token=mytoken)<jupyter_output><empty_output><jupyter_text>All your interaction with the ChemSpider database should now happen through this ChemSpider object, `cs`. Retrieve a CompoundRetrieving information about a specific Compound in the ChemSpider database is simple.Let’s get the Compound with [ChemSpider ID 2157](http://www.chemspider.com/Chemical-Structure.2157.html):<jupyter_code>comp = cs.get_compound(2157)
comp<jupyter_output><empty_output><jupyter_text>Now we have a [Compound](http://chemspipy.readthedocs.org/en/latest/api.htmlchemspipy.Compound) object called `comp`. We can get various identifiers and calculated properties from this object:<jupyter_code>print(comp.molecular_formula)
print(comp.molecular_weight)
print(comp.smiles)
print(comp.common_name)<jupyter_output>C_{9}H_{8}O_{4}
180.1574
CC(=O)Oc1ccccc1C(=O)O
Aspirin<jupyter_text>Search for a nameWhat if you don’t know the ChemSpider ID of the Compound you want? Instead use the `search` method:<jupyter_code>for result in cs.search('glucose'):
    print(result)<jupyter_output>Compound(5589)
Compound(58238)
Compound(71358)
Compound(96749)
Compound(2006622)
Compound(5341883)
Compound(5360239)
Compound(9129332)
Compound(9281077)
Compound(9312824)
Compound(9484839)
Compound(9655623)
{'fraction_non_alphanumeric': 0.09495252373813093, 'fraction_numerical': 0.049475262368815595, 'mean_word_length': 8.225806451612904, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '233695', 'license': 'MIT', 'n_tokens_mistral': 755, 'n_tokens_neox': 680, 'n_words': 159, 'path': 'examples/Getting Started.ipynb', 'repo_name': 'tom-f-oconnell/ChemSpiPy', 'size': '2001'}