It is common practice for organizations and companies to make use of proxy servers to connect to services outside their network. This can cause problems for users of the ChEMBL web services who sit behind a proxy server. So to help those users who have asked, we provide the following quick guide, which demonstrates how to access ChEMBL web services via a proxy.
Most software libraries respect proxy settings from environmental variables. You can set the proxy variable once, normally HTTP_PROXY and then use that variable to set other related proxy environment variables:
Or if you have different proxies responsible for different protocols:
On Windows, this would be:
If you are accessing the ChEMBL web services programmatically and you prefer not to clutter your environment, you can consider adding the proxy settings to your scripts. Here are some python based recipes:
1. Official ChEMBL client library
If you are working in a python based environment, we recommend you to use our client library (chembl_webresource_client), for accessing ChEMBL web services. It already offers many advantages over accessing the ChEMBL web services directly and handling proxies is yet another. All you need to do is configure proxies once and you are done:
2. Python requests library
If you decide to use requests, you have to add 'proxies' parameter to every 'get' and 'post' function call:
3. Python urllib2 library
Finally, in the lowest level library, 'urllib2' you can set a ProxyHandler and register it to URL opener:
We would like to thank Dr. Christine Rudolph for the idea and providing code snippets.