laravel-json-api/laravel
| Install | |
|---|---|
composer require laravel-json-api/laravel |
|
| Latest Version: | v5.3.0 |
| PHP: | ^8.2 |
| Laravel: | 12 · 13 |
| Older releases: | 8 – 11 |
| License: | MIT |
| Last Updated: | Jul 12, 2026 |
| Links: | GitHub · Packagist |
JSON:API for Web Artisans
Implement feature-rich JSON:API compliant APIs in your Laravel applications. Build your next standards-compliant API today.
Why use JSON:API and Laravel JSON:API?
Great question! Here's some reasons from this excellent article by Denisa Halmaghi:
Why Use JSON:API?
- Standardised, consistent APIs.
- Feature rich - some of which are: sparse fieldsets (only fetch the fields you need), filtering, sorting, pagination, eager loading for relationships (includes, which solve the N+1 problem).
- Easy to understand.
Why use Laravel JSON:API?
- Saves a lot of development time.
- Highly maintainable code.
- Great, extensive documentation.
- Strong conventions, but also highly customisable.
- Makes use of native Laravel features such as policies and form requests to make the shift easier for developers.
- Beautiful, expressive Nova-style schemas.
- Fully testable via expressive test helpers.
class PostSchema extends Schema
{
/**
* The model the schema corresponds to.
*
* @var string
*/
public static string $model = Post::class;
/**
* The maximum include path depth.
*
* @var int
*/
protected int $maxDepth = 3;
/**
* Get the resource fields.
*
* @return array
*/
public function fields(): array
{
return [
ID::make(),
BelongsTo::make('author')->type('users')->readOnly(),
HasMany::make('comments')->readOnly(),
Str::make('content'),
DateTime::make('createdAt')->sortable()->readOnly(),
DateTime::make('publishedAt')->sortable(),
Str::make('slug'),
BelongsToMany::make('tags'),
Str::make('title')->sortable(),
DateTime::make('updatedAt')->sortable()->readOnly(),
];
}
/**
* Get the resource filters.
*
* @return array
*/
public function filters(): array
{
return [
WhereIdIn::make($this),
WhereIn::make('author', 'author_id'),
];
}
/**
* Get the resource paginator.
*
* @return Paginator|null
*/
public function pagination(): ?Paginator
{
return PagePagination::make();
}
}
Documentation
See our website, laraveljsonapi.io
Tutorial
New to JSON:API and/or Laravel JSON:API? Then the Laravel JSON:API tutorial is a great way to learn!
Follow the tutorial to build a blog application with a JSON:API compliant API.
Installation
Install using Composer
composer require laravel-json-api/laravel
See our documentation for further installation instructions.
Upgrading
When upgrading you typically want to upgrade this package and all our related packages. This is the recommended way:
composer require laravel-json-api/laravel --no-update
composer require laravel-json-api/testing --dev --no-update
composer up "laravel-json-api/*" cloudcreativity/json-api-testing
Example Application
To view an example Laravel application that uses this package, see the Tutorial Application.
License
Laravel JSON:API is open-sourced software licensed under the MIT License.
Related Packages
Laravel JSON:API integration for the yocto/illuminate-database-softdeletes packa...
JSON API (jsonapi.org) support for Laravel applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v5.3.0 | ^8.2 | ^12.61.1| | MIT | |
| v5.2.1 | ^8.2 | ^11.0| | MIT | |
| v5.2.0 | ^8.2 | ^11.0| | MIT | |
| v5.1.0 | ^8.2 | ^11.0| | MIT | |
| v5.0.2 | ^8.2 | ^11.0 | MIT | |
| v5.0.1 | ^8.2 | ^11.0 | MIT | |
| v5.0.0 | ^8.2 | ^11.0 | MIT | |
| v4.1.1 | ^8.2 | ^11.0 | MIT | |
| v4.1.0 | ^8.2 | ^11.0 | MIT | |
| v4.0.0 | ^8.2 | ^11.0 | MIT | |
| v3.4.0 | ^8.1 | ^10.0 | Apache-2.0 | |
| v3.3.0 | ^8.1 | ^10.0 | Apache-2.0 | |
| v3.2.0 | ^8.1 | ^10.0 | Apache-2.0 | |
| v3.1.0 | ^8.1 | ^10.0 | Apache-2.0 | |
| v3.0.0 | ^8.1 | ^10.0 | Apache-2.0 | |
| v2.6.0 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.5.2 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.5.1 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.5.0 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.4.0 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.3.0 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.2.0 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.1.2 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.1.1 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.1.0 | ^7.4| | ^8.76| | Apache-2.0 | |
| v2.0.0 | ^7.4| | ^8.76| | Apache-2.0 | |
| v1.1.0 | ^7.4| | ^8.30 | Apache-2.0 | |
| v1.0.1 | ^7.4| | ^8.30 | Apache-2.0 | |
| v1.0.0 | ^7.4| | ^8.30 | Apache-2.0 |
Pre-releases (10)
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.0.0-beta.5 | ^7.4| | ^8.30 | Apache-2.0 | |
| v1.0.0-beta.4 | ^7.4| | ^8.0 | Apache-2.0 | |
| v1.0.0-beta.3 | ^7.4| | ^8.0 | Apache-2.0 | |
| v1.0.0-beta.2 | ^7.4| | ^8.0 | Apache-2.0 | |
| v1.0.0-beta.1 | ^7.4| | ^8.0 | Apache-2.0 | |
| v1.0.0-alpha.5 | ^7.4| | ^8.0 | Apache-2.0 | |
| v1.0.0-alpha.4 | ^7.4| | ^8.0 | Apache-2.0 | |
| v1.0.0-alpha.3 | ^7.4| | ^8.0 | Apache-2.0 | |
| v1.0.0-alpha.2 | ^7.4| | ^8.0 | Apache-2.0 | |
| v1.0.0-alpha.1 | ^7.4| | ^8.0 | Apache-2.0 |