Skip to main content

Command Palette

Search for a command to run...

cURL for beginners

Published
2 min read
V
Blog on different tools and technology or concept that useful for the begineer that start their jouney in software industry

In this article we are going through the cURL and understanding the server and how it use and work, so before moving toward cURL first let’s discuss what is server exactly?

Server :-

Server is nothing but a machine which on for the 24/7 and able to serve or handle the request from the client.

Client may be from browser, terminal, Postman, Requestly…, and every server have their own IP address so that we can send request to particular server like someone wants to comes to my home its need my address.

Why we need to talk to Server :-

let’s understand with example like why we need to talk with doctor because we need and doctor have kind of thing. similarly we talk to server because of

  • Server have websites (HTML, CSS, JS )

  • Server have database and data

  • Server have authentication, blog, product..etc

cURL - Client URL -

Client URL is a technique to send a request to server through terminal not via browser, Postman or …

cURL support in all the os like macOS, windows and linux via their terminal and it is open source.

Basic cURL command -

Sending GET Request - To sending the request to server enter command into terminal and get command is used to getting the content or data from the server.

curl [option] [URL]

# URL - URL of the server or API
curl https://hashnode.com

Sending POST Request - Post Request is used when we want to send data to server to store or validate while authentication , form fillup , sending data. for POST request we need to enter command

curl -X POST "URL" \
 -H "Content-Type: application/json" \
  -d '{"email":"xyz@mail.com", "password":"123456"}'

Understanding the Response -

Genrally when we send request to server then after process the request by server it send response and response contain a lot information but two main thing is-

Status Code - it is standerd code that use to understand the status of the request

Data - data may by json, html-page, image, text, video, audio…etcs