How to cURL with a Proxy
cURL is an extremely versatile library that lets you transfer data to and from servers. cURL can use proxies to access target servers, and has become the industry standard over the decades. This is why we always advise new users to test their proxy settings and gates (or endpoints) with a simple cURL string.
If you want to find out more about cURL, read this article:
Using cURL with a proxy
Most Windows and macOS devices come with pre-installed cURL libraries (libcurl), but most users are unaware of how to use it properly and how to cURL with a proxy.
In reality, curling with a proxy is very simple. All it takes is a variable in the cURL syntax. There are several variables that let you set up proxies with cURL.
--proxy command with:
This command will use the HTTP protocol with the proxy:
This sets HTTPS as the protocol for the proxy:
You can set proxy protocols through the prefix by using any of the following prefixes:
http:// https:// socks4:// socks5:// socks4a:// socks5h://
This syntax sets the proxy protocol to the one you specify for the URL:
Since cURL is syntax-dependent, it offers no user interaction. That means you have to define a proxy in the cURL syntax. To do this, use the command below and enter proxy information, for example:
Curl -x gate.smartproxy:7000 https://ipinfo.io
We use ipinfo.io in this example because it returns the proxy information and is very helpful when you want to be sure that you are using a proxy correctly.
If you want to cURL an authentication request to Google’s ClientLogin API through a proxy, you would tweak the usual cURL with the proxy parameter, as so:
Curl -x gate.smartproxy:7000 https://www.google.com/accounts/ClientLogin \ [...]
This cURL example will pull data from the API through the proxy server, and the API will only see the proxy IP address.
Remember, you can also use the
--proxy command instead of
To check a random rotating proxy on https://ipinfo.io with a cURL, use the following syntax:
Curl -x gate.smartproxy.com:7000 https://ipinfo.io
This syntax will send a request to ipinfo.io with the HTTPS protocol and the gate.smartproxy.com:7000 endpoint (gate). This will work only if you have whitelisted your IP address in the Dashboard.
To check the same proxy with proxy user credentials (login:pass), you must use the
-U parameter. Note that the parameter uses the capital U:
Curl -U username:password -x gate.smartproxy.com:7000 https://ipinfo.io
Why check proxies with cURL
We use cURL because it is the easiest way to check your proxy endpoint setup before you start data scraping. cURL is a standing industry standard for over 20 years, which has proven stable, light and effective.
Read these articles to learn more:
As always, using Smartproxy lets you send unlimited concurrent requests from different IP addresses (including sticky IP sessions). This lets you web scrape quicker or pull a lot more data from public APIs.
Read more about proxy settings in our Help documents.