Lazy JSON Pages is a JSON API Scraper for PHP

Lazy JSON Pages is a framework-agnostic API scraper that loads items from any paginated JSON API into a Laravel lazy collection. It is highly customizable, so you can make it work with any PHP project and any JSON API that has paginated results:

use Illuminate\Support\LazyCollection;

$result = LazyCollection::fromJsonPages($source)
    ->totalPages('pagination.total_pages')
    ->async(requests: 3)
    ->throttle(requests: 100, perMinutes: 1)
    ->collect('data.*');

Though Lazy JSON pages return data as a Laravel lazy collection, you can use this package with any PHP project as well. Since it uses Guzzle, you can easily customize client behavior via middleware needed for the target API you're consuming.

Main Features

You can learn more about this package, get full installation instructions, and view the source code on GitHub.


The post Lazy JSON Pages is a JSON API Scraper for PHP appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.