Skip to content

Latest commit

 

History

History
81 lines (50 loc) · 2.42 KB

README.md

File metadata and controls

81 lines (50 loc) · 2.42 KB

What is cURL and What Does It Mean

Oxylabs promo code

cURL (client URL) is an open-source command line tool, and a cross-platform library (libcurl) used to transfer data between servers, distributed to nearly all new operating systems. cURL programming is used almost everywhere where sending or receiving data through internet protocols is required.

This article gives you an overview of cURL.

For a detailed explanation, see our blog post.

Sending requests

To use curl, write curl followed by the URL. This sends a GET request.

curl https://httbin.org/get 

To send a POST request to a URL, the -d (or –data) flag is used:

curl -d "name=something&value=somethingelse" https://jsonplaceholder.typicode.com/posts/

Sending such a request should return:

{
  "name": "something",
  "value": "somethingelse",
  "id": 101
}

We can also send POST requests in JSON form by adding the header Content-Type: application/json:

curl -H "Content-Type: application/json" --data "{\"data\":\"some data\"}"  https://jsonplaceholder.typicode.com/posts/

Following redirects

Add -L to follow redirects:

curl -L https://google.com

Connecting through a proxy

cURL can be used to connect to any destination through a proxy:

curl --proxy proxyaddress:port https://jsonplaceholder.typicode.com/

Credential details can be sent through the -U flag.

curl --proxy proxy:port -U “username:password” https://jsonplaceholder.typicode.com/

Some websites will require authentication by themselves before they accept any connection request. A similar flag -u is used for server authentication:

curl -u username:password https://jsonplaceholder.typicode.com/

If you wish to learn more about cURL, see our blog post.