Lomkit / laravel-rest-api by GautierDele

A package to build quick and robust rest api for the Laravel framework.
28,505
547
9
Package Data
Maintainer Username: GautierDele
Maintainer Contact: gautier@lomkit.com (Gautier Deleglise)
Package Create Date: 2023-04-23
Package Last Update: 2025-08-02
Home Page: https://laravel-rest-api.lomkit.com/
Language: PHP
License: MIT
Last Refreshed: 2025-08-04 15:25:23
Package Statistics
Total Downloads: 28,505
Monthly Downloads: 2,579
Daily Downloads: 101
Total Stars: 547
Total Watchers: 9
Total Forks: 32
Total Open Issues: 20

Laravel Rest Api

Laravel Rest Api is an elegant way to expose your app through an API, it takes full advantage of the Laravel ecosystem such as Policies, Controllers, Eloquent, ...

Requirements

PHP 8.1+ and Laravel 10.0+

Documentation, Installation, and Usage Instructions

See the documentation for detailed installation and usage instructions.

What It Does

You'll find multiple endpoints exposed when using this package such as mutating, searching, showing, deleting, ...

Here is a quick look at what you can do using API search method:

// POST api/posts/search
{
    "search": {
        "scopes": [
            {"name": "withTrashed", "parameters": [true]}
        ],
        "filters": [
            {
                "field": "id", "operator": ">", "value": 1, "type": "or"
            },
            {
                "nested": [
                    {"field": "user.posts.id", "operator": "<", "value": 2},
                    {"field": "user.id", "operator": ">", "value": 3, "type": "or"}
                ]
            }
        ],
        "sorts": [
            {"field": "user_id", "direction": "desc"},
            {"field": "id", "direction": "asc"}
        ],
        "selects": [
            {"field": "id"}
        ],
        "includes": [
            {
                "relation": "posts",
                "filters": [
                     {"field": "id", "operator": "in", "value": [1, 3]}
                ],
                "limit": 2
            },
            {
                "relation": "user",
                "filters": [
                    {
                        "field": "languages.pivot.boolean",
                        "operator": "=",
                        "value": true
                    }
                ]
            }
        ],
        "aggregates": [
            {
                "relation": "stars",
                "type": "max",
                "field": "rate",
                "filters": [
                    {"field": "approved", "value": true}
                ]
            },
        ],
        "instructions": [
          {
            "name": "odd-even-id",
            "fields": [
              { "name": "type", "value": "odd" }
            ]
          }
        ],
        "gates": ["create", "view"],
        "page": 2,
        "limit": 10
    }
}

Roadmap

  • Metrics support
  • Refactor the response class
  • Alias for includes / aggregates