PHPackages                             giadc/json-api-request - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. giadc/json-api-request

AbandonedArchivedLibrary

giadc/json-api-request
======================

A package for handling JSON API requests

3.0.4(1y ago)28.0k1MITPHPPHP ^8.0.2

Since Feb 29Pushed 1y ago3 watchersCompare

[ Source](https://github.com/giadc/json-api-request)[ Packagist](https://packagist.org/packages/giadc/json-api-request)[ RSS](/packages/giadc-json-api-request/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (27)Used By (1)

JSON API Request
================

[](#json-api-request)

A package for automating pagination, filtering, sorting, and includes when working with the [JSON API](http://jsonapi.org/) standard.

Installation
------------

[](#installation)

`composer install giadc/json-api-request`

Basic Usage
-----------

[](#basic-usage)

### RequestParams

[](#requestparams)

Request Params provides objects for pulling/modifying HttpFoundation Requests that compile with JSON API V1.0.

Example:

```
GET /articles?include=author,comments.author&page[number]=3&page[size]=20&filter[author]=frank&sort=-created,title&fields[author]=name,age
```

```
use Giadc\JsonApiRequest\Requests\RequestParams;

// By default it creates params from Globals
$request = new RequestParams();

// Get Includes
$request->getIncludes()->toArray();
// outputs: ['author', 'comments.author']

// Get Page Details
$request->getPageDetails()->toArray();
// outputs: ['page' => ['number => 3, 'size' => 20]]

// Get Sorting
$request->getSortDetails()->toArray();
// outputs: [['field' => 'title', 'direction' => 'ASC'], ['field' => 'created', 'direction' => 'DESC']]

// Get Filters
$request->getFiltersDetails()->toArray();
// outputs: ['author' => ['frank']]

// Get Full Pagination
$request->getFullPagination();
// outputs: [{Pagination}, {Includes}, {Sorting}, {Filters}]

// Get Fields
$request->getFields()->toArray();
// outputs: ['author' => ['name', 'age']]
```

### Request Objects

[](#request-objects)

All Objects implements the RequestInterface and give access the following methods: `getParamsArray()`, `getQueryString()`

#### Includes

[](#includes)

```
$includes = new Includes(['author', 'comments.author');
$includes->add('site');
$includes->getQueryString();
//outputs: 'include=author,comments.author,site'
```

#### Pagination

[](#pagination)

Pagination sets a defaults the pages size if not provided. It will Also allow you to set max it is able to return by settings the `PAGINATION_DEFAULT` and `PAGINATION_MAX` env variables.

```
$pagination = new Pagination(2, 20);
$pagination->getQueryString();
//outputs: 'page[number]=2&page[size]=20'

// PAGINATION_MAX=25
$pagination = new Pagination(2, 1000);
$pagination->getQueryString();
//outputs: 'page[number]=2&page[size]=25'
```

#### Sorting

[](#sorting)

```
$sorting = new Sorting('-created,title');
$sorting->setSorting();
$sorting->getQueryString('created,-title');
//outputs: 'sort=created,title'
```

#### Filters

[](#filters)

```
$filters = new Filters(['author' => 'frank');
$filters->addFilter('author', 'bob');
$filters->getQueryString();
//outputs: 'filter[author]=frank,bob'
```

#### Excludes

[](#excludes)

```
$filters = new Excludes(['author' => 'country');
$filters->add('author', 'age');
$filters->getQueryString();
//outputs: 'excludes[author]=country,age'
```

#### Fields

[](#fields)

```
$filters = new Fields(['author' => 'name');
$filters->add('author', 'age');
$filters->getQueryString();
//outputs: 'fields[author]=name,age'
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 57.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~122 days

Recently: every ~170 days

Total

26

Last Release

654d ago

Major Versions

0.4.4 → 1.0.02016-12-22

0.5.0-alpha → 1.0.12017-05-02

1.2.1 → 2.0.02020-11-17

2.x-dev → 3.0.02022-09-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/98443c90baa66d3472ebe1dc3fb9ff843a6dd278b7b0a52e8c7732e722c6494e?d=identicon)[giadc-dev](/maintainers/giadc-dev)

---

Top Contributors

[![rmarganti](https://avatars.githubusercontent.com/u/1193396?v=4)](https://github.com/rmarganti "rmarganti (22 commits)")[![dhill2-gannett](https://avatars.githubusercontent.com/u/225896226?v=4)](https://github.com/dhill2-gannett "dhill2-gannett (16 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/giadc-json-api-request/health.svg)

```
[![Health](https://phpackages.com/badges/giadc-json-api-request/health.svg)](https://phpackages.com/packages/giadc-json-api-request)
```

###  Alternatives

[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[statamic/cms

The Statamic CMS Core Package

4.8k3.2M720](/packages/statamic-cms)[laravel/reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

1.5k9.4M48](/packages/laravel-reverb)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k15.7k4](/packages/elgg-elgg)[api-platform/http-cache

API Platform HttpCache component

223.2M7](/packages/api-platform-http-cache)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
