API access to total counts of tickets

  • 18 February 2014
  • 13 replies
  • 246 views

What about an API access to the counts of tickets in views? This would really be a great feature to display in KPI dashboards.


This was an unofficial request by me half a year ago. And: the guys implemented it though I only sent some emails.


And this is how they've done it:



You can get the ticket count with the following api call:



http://domain.freshdesk.com/helpdesk/tickets/summary.xml?view_name=all


But this count is not possible on Custom Views, but only default views.


Supported views : all, open, overdue, due_today, on_hold, new, new_and_my_open, my_groups_open, my_overdue


BTW, this is not a real-time count, there will be a delay of 5 Mins and this API call will have same 1000 API per hour limit



We use Basic Authentication with "username:password" combination or "apikey:X" combination, that has to be passed in the authorization header of the HTTP request to authenticate all our api calls.



Refer:

https://github.com/johnpaulh/mysamples#troubleshoot


eg: using curl:


curl -u email:password -X GET http://yourdomain.freshdesk.com/helpdesk/tickets/summary.xml?view_name=all


Also Ruby samples can be found:

https://github.com/freshdesk/fresh-samples/tree/master/Ruby_api_samples


If you want to try it using a simple php page, just use this simple code (and skip all this xml stuff, curl does it for you):


<?php

$curl = curl_init('http://yourdomain.freshdesk.com/helpdesk/tickets/summary.xml?view_name=open');


curl_setopt($curl, CURLOPT_FAILONERROR, true);

curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curl, CURLOPT_USERPWD, 'yourusername:yourpassword');

curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec($curl);

echo "<h1> Open tickets: ".$result."</h1>";

?>


Great, hm?! ;)



This topic has been closed for comments

13 replies

Has any progress been made in allowing an API call from a custom view? Or pulling the open/closed count from individual groups?

Needed for custom views. 


This is a feature that is definitely on our roadmap. I don't have an ETA right now, but I will update this post once I have an update.


So with a bit of guess work I was able to construct this which is not documented anywhere (as far as I can tell) but does work:


https://newicon.freshdesk.com/helpdesk/tickets/summary.json?view_id=318263


The view_id being the id of the custom view. This is really helpful in our use case where we want to see the total open tickets for our Support team. And the total open tickets for the sales team on our company internal dashboard.


This hopefully answers your question @BrianLee



Whoops spoke too soon, it seems to give the answer of 2 every time..... Doh!


ah, too bad I cannot see that page. Is there any way I can reproduce this?

{"require_login":true}


Badge +3

I second this suggestion.


Once multiple products and groups are in use, the supported views lose their value.


It is suggested above that the ID of a custom view can be used, but I am not getting consistent results with this.


Thanks for listening,

geirmund


Userlevel 4
Badge +12

Hi,




We've recently introduced the Filter tickets API wherein you'd get the count of tickets in a particular view along with the results.





{
"total":49,
"results":[
{
"cc_emails":["clark.kent@kryptonspace.com"],
"fwd_emails":[ ],
"reply_cc_emails":[ ],
"fr_escalated":false,
"spam":false
}
}



Cheers!


Is there a way to get the total count of tickets from the Freshdesk API ?


Userlevel 4
Badge +12

@Ashok: You can use the Filter tickets API to fetch the results along with the total count as illustrated in the example above.


Cheers!

@Aravind S I think it's better to add option to only get the total count of ticket and exclude the result.

In my case, I only need to know the number of ticket, if the response contains detail of ticket, the rest performance isn't good.


Maybe it worth to develop the API, and I think many users will love it.


Userlevel 4
Badge +12

@Lambang, Can you please help us with your use-case for requesting the total count of tickets? Are you trying to display this information on a screen?


Cheers!

I want this too