PHPackages                             dorvidas/laravel-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. [API Development](/categories/api)
4. /
5. dorvidas/laravel-json-api-client

ActiveLaravel-package[API Development](/categories/api)

dorvidas/laravel-json-api-client
================================

Laravel client for easy access of data from {json:api} APIs

v0.0.1-alpha(7y ago)21071[1 issues](https://github.com/dorvidas/laravel-json-api-client/issues)MITPHP

Since Jul 30Pushed 7y ago1 watchersCompare

[ Source](https://github.com/dorvidas/laravel-json-api-client)[ Packagist](https://packagist.org/packages/dorvidas/laravel-json-api-client)[ RSS](/packages/dorvidas-laravel-json-api-client/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Laravel {json:api} client
=========================

[](#laravel-jsonapi-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:

```
$response = JsonApiClient::get('users');
//Let's return this data to view
return view('users', ['users'=> $response->data]);
```

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

[](#installation)

- Install package `composer require dorvidas\laravel-json-api-client`.
- Add service provider `Dorvidas\JsonApiClient\Providers\JsonApiClientServiceProvider::class` to `config/app.php`
- Publish vendor config `php artisan vendor:publish`.

Usage
-----

[](#usage)

### Getting the client

[](#getting-the-client)

You can get client in several ways:

- Via Facade `\Dorvidas\JsonApiClient\Facades\JsonAPIClient`
- Resolving from service container `Dorvidas\JsonApiClient\JsonApiClient::class`

### Making requests

[](#making-requests)

- get($endpoint)

```
JsonApiClient::get('users'); //get users
```

- post($endpoint)

```
JsonApiClient::jsonData([])->post('users');//store user
```

- patch($endpoint)

```
JsonApiClient::jsonData([])->patch('users');//do patch request
```

#### Request options

[](#request-options)

- `JsonApiClient::get('users')->withIncludes(['posts'])` - adds query param `include=posts` to request URL. See
- `JsonApiClient::get('users')->withFields(['user'=> ['id','name']])` - adds query param `fields[users]=id,name`. See
- `JsonApiClient::get('users')->withFilters(['users'=>['id'=>['eq'=>1]]])` - 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 .
- `JsonApiClient::get('users')->withQuery(['field'=>1])` - adds query param `field=1=1`. In theory adding filter, includes, fields and pagination fields should be sufficient.
- `JsonApiClient::limit($limit, $offset)->get('users')` - add result constraints to query param `page\[limit\]=x&amp;page\[offet\]=y. See
- `JsonApiClient::formData(['name'=>'John'])->post('users')` - define post form data. Form data can contain files i.e `JsonApiClient::formData(['image'=> $request->file('image')])->post('photos')`.
- `JsonApiClient::jsonData(['name'=>'John'])->post('users')` - define post JSON data.
- `JsonApiClient::throwException(true)` - whenever non 2xx status code received and appropriate exception is thrown. Set to `false` if you want handel request response status yourself.
- `JsonApiClient::token($accessToken)->get('users')` - define access token which will be added to `Authorization:Bearer {$accessToken}` header. Note, if there is `jwt` session variable there is no need to set token here, because access token will be added to request automatically.

### Handling response

[](#handling-response)

Requests will return `JsonApiResponse` 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. Also it has helper functions
- `$resopnse->meta('count')` - return meta data with key `count`.

### Exceptions

[](#exceptions)

//@todo

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

2841d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61196e3395ce51576cd0bdfefca7c63ef2d4f763ddb441b414324c3eeb6f0e66?d=identicon)[dorvidas](/maintainers/dorvidas)

### Embed Badge

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

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[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)
