Question

Retrieve total lifetime ticket count using Freshdesk API without looping through with page=1, page=2 etc

  • 15 February 2022
  • 1 reply
  • 312 views

Hi!

 

I am wondering if it is possible to retrieve the total lifetime ticket count using the Freshdesk API! I have only found one method, and it includes doing a for loop with page as the iterator, but this seems very inefficient to me, and it always results in me sending too many requests and getting no data back.

 

Is there a simpler way to do this that does not cause too many requests to be sent and not using a for loop?

 

Kind regards,

 

Guy


1 reply

Hello

I think the iterative loop is the only way, but there are a few things you can do to ensure the data is accurate.

You may be subject to throttling if you’re making too many requests within a minute. The rate limits can be found here: https://api.freshservice.com/#rate_limit 

If you’re not already dong so, you can reduce the number of request being made by maximising the number of returned entries for each request by appending ‘?per_page=100’ to your request.I think this is the maximum number you can return with a single request, but it’s more than the default of 10.

Then, slow down the number of requests you are making in a minute by either:

  • reading the ‘Retry-After’ header returned in the response for a request, and pausing for that time before retrying;

or

  • putting in pauses between a certain number of requests to ensure you never go over the limits specified in the rate limit table.

There is another caveat mentioned on the API page for the ‘View All Tickets’ endpoint: https://api.freshservice.com/#view_all_ticket

  1. By default only tickets that have been created within the past 30 days will be returned. For older tickets, use the updated_since filter.

 

My apologies if you were already aware of this. 

The other alternative is that perhaps you put in a feature request for Fresh to update their API to include a header in their response with the total number items that fit your search criteria.

 

Reply