Here is a list of APIs that can be used the following way to retrieve synonyms:
The details are here: http://words.bighugelabs.com/api.php
the details are here: http://content.dictionary.com/api (Note: "We are selective about our API partners and approve use as well as develop terms on a case-by-case basis.")
the details are here: http://watson.kmi.open.ac.uk/API/explain-syn.html
the details are here: http://thesaurus.altervista.org/
Check out this post on stackoverflow; it has a lot of good information on synonym web services.