Get perfect CURL command for getting data from API using this amazing software.

You want to write a perfect CURL command to get data from an API using PHP, Java or many other languages but either you hate writing them on your own or you just don’t know how to do it then this blog post can literally make this task much easier than you think!

The software you are gonna need is “Postman”. If you already have it than it is great else you can download it from their OFFICIAL SITE (Easy download and install).

After that just open the postman software and click the “+” button to open new tab.

Postman Curl PHP 1

In the new tab the first thing you have to do is to select which HTTP request method you want to use (GET,POST,PUT etc). After that you have to write the endpoint URL you are gonna hit to get data and third thing that is optional are the parameters that endpoint requires.

Postman curl php 2

As a demo I am going to use demo API Comments on post from Json Place Holder which returns comments on specific post. After filling all the above mentioned things and clicking “Send” button, this is how my tab looks like.

Postman curl php 3

As you can see all the things are working fine. Now for getting CURL command for this API just click on “Code” on the very right just below the “Send” button and the following window will open up. In this window select the language you want and it will generate CURL command for that API. I am going to use PHP for this tutorial. You can select any that you need.

Postman curl php 4

After that you can copy and paste the generated code in your PHP file where you want to hit that API and it will show the returned data from API.

That is it. If you have any questions regarding this blog post than feel free to ask them using my contact form or on social media account connected to this website.