The ChemSpider web services are intended to allow you to use the functionality of ChemSpider and query the data in it in your own website or program or script. There are many different webservices as described here, and also many different ways to use them.

One example of how to use them was sent to us by Jimmy Moore from the University of Manchester. He includes a call on the SimpleSearch operation of the Search web service in a perl script. THis searches the whole of ChemSpider by an input value which can be the molecule’s name, SMILES string, InChI, InChIKey, and returns the ChemSpider ID:

use strict;
my $unknown = shift;
use SOAP::Lite on_action => sub {sprintf '"%s%s"', @_};
my $token = ' '; # Your token value should be input here. I'm not going to give mine away!
my $service = SOAP::Lite -> uri('')
-> proxy('');
my $output = $service->call(SOAP::Data->name('SimpleSearch')
-> attr({xmlns => ''})
=> SOAP::Data->name('query')->value($unknown)->type('')
=> SOAP::Data->name('token')->value($token)->type(''));
my @result = $output->valueof('//SimpleSearchResult/int');
print @result;

For further background, and also an example of a perl script which uses the SMILESToInChI operation of the InChI web service see his blog page.

Please note that to use this (and some of the other) web services you need to obtain a token, by registering with ChemSpider (if you have not already), and then logging into ChemSpider and viewing your Profile page. The Security Token shown needs to be copied into the perl script itself in Jimmy’s example.

Also note that you will need to install the SOAP::Lite for Perl modules to your Perl library to run this script if you don’t already.

If you have an example of how you have used the ChemSpider web services then please reply to this ChemSpider forum post. More examples will inspire more new ideas, and also make it easier for other people trying to do similar things.

Stumble it!

5 Responses to “Example of ChemSpider web service use”

  1. Danny says:

    The perl code doesn’t work for me. I keep getting “500 Can’t connect to (connect: timeout)” when I attempt to run it.

  2. Aileen Day says:

    Perhaps you could email us at and we can work out what’s going wrong.
    I just confirmed that this script is working for us still, so should work out what’s different with your local set up and try to fix it.

  3. Karen says:

    I can use the Wen API to get back structures and formulas based on the CAS # or Name, but is there way with the CSID to get the boiling and melting points for the compound through the web API. That would be really helpful!

    - Karen

  4. Susan Richardson says:

    We do not currently have an API which will return boiling or melting points. There are a few reasons why this is the case -experimentally measured properties are only available on a subset of our records, they are harder to verify than some other kinds of data like names or identifiers, and although predicted properties should be available on all records these are calculated by tools created by other organisations and are subject to licensing constraints. I am sorry to not have a more positive answer for you, but thank you for letting us know that you would like this feature.

  5. Karen says:

    Thanks for the reply. I found that I can get BP and MP from another Web Service. (not sure if I should mention it here)

    They handle it by retuning all the reported values they have for that experimental property along with the source of the data and if any of them has reviewed/confirmed (I forget the tern they used) it lets you know that.

    That was good enough for my purposes.

    - Karen

Leave a Reply