Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jakubjv's avatar

How properly retrieve data from third party api Freshdesk in Laravel/Vue app?

I have an issue with retrieving data from the Freshdesk Developers API. I'm trying to return tickets that do not yet have a purchase assigned in our system, based on certain filters. When I output the data using something like dd(), I can see that it returns a total of 187 tickets. However, in my frontend data grid, I only see 30 tickets displayed, with 5 tickets per page.

A possible solution could be to always return only 30 records, with the remaining records generated as fake ones. But on the specific page where the user is currently located, only the real records should be shown. The fake ones would appear on other pages where the user is not currently present. This means that only 30 records are actually fetched at a time, but it would always load the next batch of 30 real records as the user navigates.

The problem is that the API doesn’t allow me to load all 187 tickets at once. Unfortunately, I have no idea how to implement this so that it works correctly. Therefore, I’m reaching out to see if anyone on StackOverflow has dealt with a similar issue.

This is my method in controller for retrieving tickets.

This is method for filter tickets in my freshdesk service file

public static function filterTickets(string $query, $alias): array
    {
        return self::simpleRequest("search/tickets?query=" . urlencode($query), [], "GET", $alias);
    }

And this is frontend component

I am trying to follow docs https://developers.freshdesk.com/api/#filter_tickets. But even when I did try to use page in query it still retrioeves me just 30 records. But in my case, total count of results/tickets in response from freshdesk api is 187.

0 likes
4 replies
webrobert's avatar

@jakubjv, I don't follow what you are trying to do... you want fake records? Or you want actual records? You want all the records? Or just 30?

jlrdw's avatar

I don't understand why you want the fake records. Sounds like you need to properly paginate the data.

jakubjv's avatar

@jlrdw You're right, I need to properly paginate data..

I did this

and updated method in freshdesk service

  public static function filterTickets(string $query, $alias, int $page = 1, int $perPage = 100): array
    {
        $url = "search/tickets?query=" . urlencode($query) . "&page=$page&per_page=$perPage";
        return self::simpleRequest($url, [], "GET", $alias);
    }

but it fails with this

  "success" => false
  "response" => "{"description":"Validation failed","errors":[{"field":"per_page","message":"Unexpected/invalid field in request","code":"invalid_field"}]}"

I think according to their docs it should work but ye i understand it doesn't work for filter tickets endpoint..but firstly I need to filter them and after that I need tou show filtered list..

jakubjv's avatar
jakubjv
OP
Best Answer
Level 2

Ok So i littler bit updated code and now it works.

Please or to participate in this conversation.