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

webfuelcode's avatar

API call with pagination

This is JSON

{
"status":"success",
"data":{
"stats":{"total":12643,"offset":0,"limit":50,"order":"desc","totalMarkets":83232},
"base":{"symbol":"USD","sign":"$"},
"photos":[{"id":1,....................................},
}
}

Above the "limit":50 is the count of items on a page.

$host = config('api_host');
        $key = config('api_key');
        $collection = Http::withHeaders([
            'x-rapidapi-host' => $host,
            'x-rapidapi-key' => $key
        ])->get('https://localhost/stats');
        return view('stats', ['collection'=>$collection['data']]);

How to put pagination on the blade page? How to send the page number to the API URL

https://localhost/stats?page=2

https://localhost/stats?page=3

https://localhost/stats?page=4

https://localhost/stats?page=5

0 likes
1 reply

Please or to participate in this conversation.