Curl is a wonderful tool for initiate REST APIs or calls. Or, you can literally open any web URL through it, and save files on public URLs through it. Its pretty light weight.

All you need is a terminal or console.

A Simple GET Rest Call

curl https://yourhost/api/getthings


curl -X GEThttps://yourhost/api/getthings

And, you will get the result of this rest endpoint on the console or terminal.

Note: In above example, I assume there is no authentication asked by REST endpoint.


Lets assume you have a REST endpoint which takes some data in a POST call.

curl -X POST -H "Content-Type: application/json" -d '{"msg": {"to": "abc-at-smail"}}' localhost:3000/api/queue/v1

Here, I’m passing a json data to rest endpoint, and mentioned that its a POST call by -X switch.

Note: You need to mention header “Content-Type: application/json” to pass a json to your endpoint. Else, your end point will take it as a string not json.

Pass Http Headers

You can pass as many headers to your rest endpoint as you want. Curl provides -H switch, and you pass multiple headers.

curl -H "Host:" -H "Authorization: xyz" -H "Content-Type: application/json" localhost:3000/api/queue/v1

Download static resource like Image

Assume you have a public url for image like, and you want to download to your machine or server.

curl -o file.png

You specify -o flag to write to a file and give a name. Else, this will display content of that resource on console.

Download html

Similarly, you can download html of resource.

curl -o file.html

This will download the htmlonly, not any other resources like image or css or javascript.

If you have any difficulty using curl, put it in comment below.