For your API calls, I recommend using the package guzzle (http://docs.guzzlephp.org/en/stable/), it's much simpler to use than curl directly.
PS : you can't really say that code is in PHP here. This is a JSON API, you can interact with it with curl, and PHP implements functions make curl calls.
With guzzle you will write something like this to make a GET call :
$client = new GuzzleHttp\Client();
$res = $client->request('GET', 'https://apiv2.shiprocket.in/v1/external/shipments/'.$shipment_id);
$res->getBody() //get the body of the response, this will contain the data sent back by the API