aedart/athenaeum-http-api

Json based API utilities
1,845
Install
composer require aedart/athenaeum-http-api
Latest Version:10.23.0
PHP:^8.4
Laravel:13
Older releases:9 – 12
License:BSD-3-Clause
Last Updated:Oct 20, 2026
Links: GitHub  ·  Packagist
Maintainer: aedart

Athenaeum Http Api

Opinionated utilities to help shape and format your API, using Laravel's API Resources.

Example

The following example shows an "API Resource", for an Eloquent User model.

use Aedart\Http\Api\Resources\ApiResource;
use Illuminate\Http\Request;

class UserResource extends ApiResource
{
    public function formatPayload(Request $request): array
    {
        return $this->withTimestamps([
            'id' => $this->getResourceKey(),
            'name' => $this->name,
            'roles' => $this->belongsToManyReference('roles')
                ->withLabel('name')
                ->withSelfLink()
                ->withResourceType();
        ]);
    }

    public function type(): string
    {
        return 'user';
    }
}

When a response is returned for a single user, the following JSON will be output:

{
    "data": {
        "id": 34,
        "name": "Retta Altenwerth Jr.",
        "created_at": "2022-10-21T14:51:43+00:00",
        "updated_at": "2022-10-21T14:51:43+00:00",
        "roles": [
            {
                "id": 23,
                "name": "Machine Operator",
                "type": "role",
                "self": "http://localhost/roles/23"
            },
            {
                "id": 56,
                "name": "File Clerk",
                "type": "role",
                "self": "http://localhost/roles/56"
            }
        ]
    },
    "meta": {
        "type": "user",
        "self": "http://localhost/users/34"
    }
}

Documentation

Please read the official documentation for additional information.

Repository

The mono repository is located at github.com/aedart/athenaeum

Versioning

This package follows Semantic Versioning 2.0.0

License

BSD-3-Clause, Read the LICENSE file included in this package

Related Packages

yadakhov/json

A simple wrapper class to work with json in PHP.

8,393 16
aedart/athenaeum-filters

Search filter utilities, based on http query parameters

2,548 0
ellipsesynergie/api-response

Simple package to handle response properly in your API

1,428,812 372
laragear/json

Easily retrieve and manipulate `Json` across your application.

4,264 35
vinelab/http

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

307,693 57

Version History

Version Released PHP Laravel License
10.23.0 ^8.4 ^v13.37.0 BSD-3-Clause
10.22.0 ^8.4 ^v13.35.0 BSD-3-Clause
10.21.0 ^8.4 ^v13.33.0 BSD-3-Clause
10.20.0 ^8.4 ^v13.32.0 BSD-3-Clause
10.19.0 ^8.4 ^v13.31.0 BSD-3-Clause
Pre-releases (1)
Version Released PHP Laravel License
7.0.0-alpha.1 ^8.1 ^v10.0.0 BSD-3-Clause