I understand you need software download apk file. It is difficult but possible.
Itself the downloading is done via a simple http request
$user_id = '0000000000000000';
$market_da = '0000000000000000000';
$device_id = '000000000000000000';
$asset_id = '1234567';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://android.clients.google.com/market/download/Download?assetId=$asset_id&userId=$user_id&deviceId=$device_id");
curl_setopt($ch, CURLOPT_COOKIE, "MarketDA=$market_da");
curl_setopt($ch, CURLOPT_USERAGENT, "AndroidDownloadManager");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Keep-Alive'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, THIS, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 250);
$data = curl_exec($ch);
here asset_id is the internal ID of the entrepreneurs in the market. Variables market_da, user_id, device_id, as you can guess, identificeret user and the phone.
The only way I know to get them to do tcpdump a real phone when he shakes apk, and see what he sends.
Get asset_id, you can use various unofficial API like
with the API, do a search for package_name, get info about the program, including assetId (if I am not mistaken in the objects returned via the API this variable is called simply id).
This method does not work for copy-protected programs (the phone shakes https and it is unclear what sends) and for programs not available in the market phone. Ie if the phone is Ukrainian, part prog in the market is not visible and for them, the script will return an error.