PHPackages                             javis/json-api-client - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. javis/json-api-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

javis/json-api-client
=====================

A simple JSON:API client library for PHP

v1.0.6(6y ago)051[1 PRs](https://github.com/javis/json-api-client/pulls)MITPHPPHP &gt;=5.5.9CI failing

Since May 15Pushed 6y ago1 watchersCompare

[ Source](https://github.com/javis/json-api-client)[ Packagist](https://packagist.org/packages/javis/json-api-client)[ RSS](/packages/javis-json-api-client/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

JsonApi Client library for PHP
==============================

[](#jsonapi-client-library-for-php)

[![Build Status](https://camo.githubusercontent.com/0cc3edde7af56f7232537b025bf23e60588cc4089027402d6a21248196e2dc9f/68747470733a2f2f7472617669732d63692e6f72672f6a617669732f6a736f6e2d6170692d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/javis/json-api-client)[![Latest Stable Version](https://camo.githubusercontent.com/2dffd6b82465e7706d082f546e3553d8a74ef4e8224d1f5f32d3517c727013b5/68747470733a2f2f706f7365722e707567782e6f72672f6a617669732f6a736f6e2d6170692d636c69656e742f762f737461626c652e737667)](https://packagist.org/packages/javis/json-api-client)[![Total Downloads](https://camo.githubusercontent.com/9d1d4e7e423b4ea4ce45e24409f5c32ec72d6d6562fc3c3e4e2d8dd1533b195b/68747470733a2f2f706f7365722e707567782e6f72672f6a617669732f6a736f6e2d6170692d636c69656e742f646f776e6c6f6164732e737667)](https://packagist.org/packages/javis/json-api-client)[![Quality Score](https://camo.githubusercontent.com/258faf3e9e9ca8ef475d74070b510839ec117f67920135cb1e39268420cbe24a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a617669732f6a736f6e2d6170692d636c69656e742e737667)](https://scrutinizer-ci.com/g/javis/json-api-client)[![License](https://camo.githubusercontent.com/8b23262d188d5e92a0c821787f0b6cd1a55b542ce93440a31be63d37b666d9bf/68747470733a2f2f706f7365722e707567782e6f72672f6a617669732f6a736f6e2d6170692d636c69656e742f6c6963656e73652e737667)](https://packagist.org/packages/javis/json-api-client)

Client for easy access of data from [{json:api}](http://jsonapi.org/) API. Making requests to API by using PHP HTTP Clients like Guzzle or CURL requires to much code. This package tries to simplify this process, by allowing to get data from API as simply as:

```
$client = new Client('http://my.api.com');
$response = $client->endpoint('users')->get();
return $response->data;
```

Requirements
------------

[](#requirements)

- PHP &gt;= 5.5.9

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

[](#installation)

```
composer require javis/json-api-client

```

Usage
-----

[](#usage)

### Configuring the client

[](#configuring-the-client)

Create an instance passing base url and an array of default [request options](http://docs.guzzlephp.org/en/stable/request-options.html), where you can set up authentication details, etc.

```
$client = new Client('http://my.api.com',[
    'headers' => ['Authorization' => 'Bearer ' . $token]
]);
```

Or pass an already configured `GuzzleHttp\Client()` object.

```
$http_client = new GuzzleHttp\Client();
$client = new Client('http://my.api.com',[], $http_client);
```

### Making requests

[](#making-requests)

- get($endpoint)

```
$client->endpoint('users')->get(); //get users
```

- post($endpoint)

```
$client->endpoint('users')->withJsonData([])->post();//store user
```

- patch($endpoint)

```
$client->endpoint('users')->withJsonData([])->patch();//do patch request
```

#### Request options

[](#request-options)

- `$client->endpoint('users')->includes(['posts'])->get()` - adds query param `include=posts` to request URL. See
- `$client->endpoint('users')->fields(['user'=> ['id','name']])->get()` - adds query param `fields[users]=id,name`. See
- `$client->endpoint('users')->filter(['users'=>['id'=>['eq'=>1]]])->get()` - adds query param `filter[users][id][eq]=1`. {json:api} is agnostic about filtering, so you can choose your filtering strategy and pass what ever array you want. See .
- `$client->endpoint('users')->withQuery(['field'=>1])->get()` - adds query param `field=1=1`. In theory adding filter, includes, fields and pagination fields should be sufficient.
- `Client::limit($limit, $offset)->get('users')` - add result constraints to query param `page[limit]=x&page[offet]=y`. See
- `$client->endpoint('users')->withFormData(['name'=>'John'])->post()` - define post form data. Form data can contain files i.e `$client->endpoint('photos')->withFormData(['image'=> $request->file('image')])->post()`.
- `$client->endpoint('users')->withJsonData(['name'=>'John'])->post()` - define post JSON data.

### Handling response

[](#handling-response)

Requests will return `Response` object. It will contain public variables:

- `$resopnse->data` - contains response data.
- `$resopnse->meta` - contains meta data of a response.
- `$resopnse->errors` - contains errors data of a response.
- `$resopnse->status` - holds HTTP status code of request.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~49 days

Recently: every ~72 days

Total

7

Last Release

2261d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6478000dc7075c623c3d4d1ba1ead3a12d4cedefc21fca8782edda556a52a7a0?d=identicon)[javis](/maintainers/javis)

---

Top Contributors

[![javis](https://avatars.githubusercontent.com/u/951888?v=4)](https://github.com/javis "javis (4 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

---

Tags

httpjsonapiclient

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/javis-json-api-client/health.svg)

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

###  Alternatives

[vinelab/http

An http library developed for the laravel framework. aliases itself as HttpClient

59300.2k11](/packages/vinelab-http)[printu/customerio

PHP API for Customer.io

241.1M2](/packages/printu-customerio)[jsor/hal-client

A lightweight client for consuming and manipulating Hypertext Application Language (HAL) resources.

2425.9k1](/packages/jsor-hal-client)[rap2hpoutre/jacky

Opinionated REST JSON HTTP API client for laravel

174.4k](/packages/rap2hpoutre-jacky)[meteocontrol/vcom-api-client

HTTP Client for meteocontrol's VCOM API - The VCOM API enables you to directly access your data on the meteocontrol platform.

175.7k1](/packages/meteocontrol-vcom-api-client)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

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