PHPackages                             flarum/json-api-server - 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. flarum/json-api-server

ActiveLibrary

flarum/json-api-server
======================

A fully automated JSON:API server implementation in PHP.

1.0.4(2y ago)253.4k↓27.4%1MITPHPPHP &gt;=8.1

Since Mar 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/flarum/json-api-server)[ Packagist](https://packagist.org/packages/flarum/json-api-server)[ GitHub Sponsors](https://github.com/flarum)[ Fund](https://opencollective.com/flarum)[ RSS](/packages/flarum-json-api-server/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (9)Versions (11)Used By (0)

json-api-server
===============

[](#json-api-server)

[![Pre Release](https://camo.githubusercontent.com/87e947dad8c6f14088b8d7ee986218fa23ef216ed3f10cfaeeea0390fc0e174c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f767072652f746f62797a2f6a736f6e2d6170692d7365727665722e7376673f7374796c653d666c6174)](https://github.com/tobyzerner/json-api-server/releases)[![License](https://camo.githubusercontent.com/348659f9d37159b3b1a68ab6cc596fc776419a81fe9217696245d7e2da1888f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f62797a2f6a736f6e2d6170692d7365727665722e7376673f7374796c653d666c6174)](https://packagist.org/packages/tobyz/json-api-server)

json-api-server is a [JSON:API](http://jsonapi.org) server implementation in PHP.

It allows you to build a feature-rich API by defining resource schema and connecting it to your application's database layer.

Based on your schema definition, the package will serve a complete API that conforms to the [JSON:API specification](https://jsonapi.org/format/), including support for:

- **Showing** individual resources (`GET /articles/1`)
- **Listing** resource collections (`GET /articles`)
- **Sorting**, **filtering**, **pagination**, and **sparse fieldsets**
- **Compound documents** with inclusion of related resources
- **Creating** resources (`POST /articles`)
- **Updating** resources (`PATCH /articles/1`)
- **Deleting** resources (`DELETE /articles/1`)
- **Content negotiation**
- **Error handling**
- **Extensions** including Atomic Operations
- **Generating OpenAPI definitions**

Documentation
-------------

[](#documentation)

[Read the documentation](https://tobyzerner.github.io/json-api-server)

Example
-------

[](#example)

The following example uses an Eloquent model in a Laravel application. However, json-api-server can be used with any framework that can deal in PSR-7 Requests and Responses. Custom behavior can be implemented to support other ORMs and data persistence layers.

```
use App\Models\User;
use Tobyz\JsonApiServer\Laravel;
use Tobyz\JsonApiServer\Laravel\EloquentResource;
use Tobyz\JsonApiServer\Laravel\Filter;
use Tobyz\JsonApiServer\Endpoint;
use Tobyz\JsonApiServer\Schema\Field;
use Tobyz\JsonApiServer\Schema\Type;
use Tobyz\JsonApiServer\JsonApi;

class UsersResource extends EloquentResource
{
    public function type(): string
    {
        return 'users';
    }

    public function newModel(Context $context): object
    {
        return new User();
    }

    public function endpoints(): array
    {
        return [
            Endpoint\Show::make(),
            Endpoint\Index::make()->paginate(),
            Endpoint\Create::make()->visible(Laravel\can('create')),
            Endpoint\Update::make()->visible(Laravel\can('update')),
            Endpoint\Delete::make()->visible(Laravel\can('delete')),
        ];
    }

    public function fields(): array
    {
        return [
            Field\Attribute::make('name')
                ->type(Type\Str::make())
                ->writable()
                ->required(),

            Field\ToOne::make('address')->includable(),

            Field\ToMany::make('friends')
                ->type('users')
                ->includable(),
        ];
    }

    public function filters(): array
    {
        return [Filter\Where::make('id'), Filter\Where::make('name')];
    }
}

$api = new JsonApi();

$api->resource(new UsersResource());

/** @var Psr\Http\Message\ServerRequestInterface $request */
/** @var Psr\Http\Message\ResponseInterface $response */
try {
    $response = $api->handle($request);
} catch (Throwable $e) {
    $response = $api->error($e);
}
```

Contributing
------------

[](#contributing)

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.4% 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 ~35 days

Recently: every ~60 days

Total

8

Last Release

555d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/504687?v=4)[Daniël Klabbers](/maintainers/Luceos)[@luceos](https://github.com/luceos)

![](https://avatars.githubusercontent.com/u/16573496?v=4)[IanM](/maintainers/imorland)[@imorland](https://github.com/imorland)

![](https://avatars.githubusercontent.com/u/1630413?v=4)[Gregor Hammerschmidt](/maintainers/GreXXL)[@GreXXL](https://github.com/GreXXL)

---

Top Contributors

[![tobyzerner](https://avatars.githubusercontent.com/u/128862?v=4)](https://github.com/tobyzerner "tobyzerner (236 commits)")[![SychO9](https://avatars.githubusercontent.com/u/20267363?v=4)](https://github.com/SychO9 "SychO9 (13 commits)")[![bertramakers](https://avatars.githubusercontent.com/u/959026?v=4)](https://github.com/bertramakers "bertramakers (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![asispts](https://avatars.githubusercontent.com/u/79239132?v=4)](https://github.com/asispts "asispts (3 commits)")[![davwheat](https://avatars.githubusercontent.com/u/7406822?v=4)](https://github.com/davwheat "davwheat (1 commits)")[![basemaster](https://avatars.githubusercontent.com/u/4114790?v=4)](https://github.com/basemaster "basemaster (1 commits)")[![acorncom](https://avatars.githubusercontent.com/u/802505?v=4)](https://github.com/acorncom "acorncom (1 commits)")[![smtlab](https://avatars.githubusercontent.com/u/3519592?v=4)](https://github.com/smtlab "smtlab (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/flarum-json-api-server/health.svg)

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

###  Alternatives

[bref/bref

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k9.6M55](/packages/bref-bref)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[aimeos/aimeos-core

Full-featured e-commerce components for high performance online shops

4.5k346.9k48](/packages/aimeos-aimeos-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)

PHPackages © 2026

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