Unable to use PHP API



I have been starting with PHP API and started with the most simple one I though

I put in my API key and domain but always get false reply. I´m running PHP 7.1.28 on my local machine (localhost) but have also tested it on my server.

Curl is enabled.

I always get “no deals created yet”.

This code is exactly the same as in the documentations.

What I´m I missing?


// Content of get_all_deals.php

// Pipedrive API token
$api_token = 'token';
// Pipedrive company domain
$company_domain = 'domain';
//URL for Deal listing with your $company_domain and $api_token variables
$url = 'https://'.$company_domain.'.pipedrive.com/v1/deals?limit=500&api_token=' . $api_token;
//GET request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo 'Sending request...' . PHP_EOL;
$output = curl_exec($ch);
// Create an array from the data that is sent back from the API
// As the original content from server is in JSON format, you need to convert it to a PHP array
$result = json_decode($output, true);
// Check if data returned in the result is not empty
if (empty($result['data'])) {
    exit('No Deals created yet' . PHP_EOL);
// Iterate over all found Deals
foreach ($result['data'] as $key => $deal) {
    $deal_title = $deal['title'];
       // Print out a deal title with its ID
       echo '#' . ($key + 1) . ' ' .  $deal['title'] . ' ' . '(Deal ID:'. $deal['id'] . ')' . PHP_EOL;  

hi. Do you have existing deals that you can’t retrieve via API?
If you don’t, the message is clear… You just need to create some and then you’ll see them when you send that request.


Hi Dani,

I have some 100 deals active currently,

If I run https://api.pipedrive.com/v1/deals?status=all_not_deleted&start=0&api_token=TOKEN then I get a list of them all.

But the PHP is just not working.


Are you using the same API token?


Yes, I´m using the same API token.


Just to double check…
Are you saying that this doesn’t return anything

$url = 'https://'.$company_domain.'.pipedrive.com/v1/deals?limit=500&api_token=' . $api_token;

but this does?

$url = 'https://'.$company_domain.'.pipedrive.com/v1/deals?status=all_not_deleted&start=0&api_token=' . $api_token;

…with all the rest of the code being the same?


What I´m saying that I´m using the Code (image below) from the Tutorial from Pipedrive documentation. Just changing the API key and domain to my own.

If I copy/paste the $URL from the code and just paste it into chrome I get response. But when I try to run it with PHP I get no response.


Here is a picture of the exact same code which I´m running on my local machine.

Have tested running it in CMD and simply opening it in Chrome (IIS and PHP7.1.28)


What happens if you just try to read a simple url from curl in php? Does it work?

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.w3.org/TR/PNG/iso_8859-1.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

I am also having trouble with the PHP; encountering the same issues as above in this string. When I use the code in the tutorial from PipeDrive and change to my API token and domain name I run the PHP code and get no response.
image|690x392 .


Perhaps the request failed or the result is not valid JSON. Try adding:

right before: