bhry98/laravel-api-response

A fluent, extensible, and highly configurable API response toolkit for Laravel applications.

Maintainers

Package info

github.com/bhry98/laravel-api-response

pkg:composer/bhry98/laravel-api-response

Transparency log

Statistics

Installs: 696

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.0 2026-07-28 09:25 UTC

This package is auto-updated.

Last update: 2026-07-30 16:09:29 UTC


README

Latest Version on Packagist Total Downloads License

A fluent, extensible, highly configurable API response toolkit for Laravel 11, 12 and 13. Zero configuration to get started, endlessly customizable when you need it.

return api()->created($user);

return api()
    ->success()
    ->message('User created.')
    ->data($user)
    ->meta(['foo' => 'bar'])
    ->headers(['X-Foo' => 'bar'])
    ->send();

📖 Full documentation

bhry98.github.io/packages/laravel-api-response

Installation

composer require bhry98/laravel-api-response

The service provider and the ApiResponse facade alias are auto-discovered - nothing else is required.

Highlights

  • A single fluent builder (api() / ApiResponse) with ready-made HTTP and business response shortcuts.
  • Fully configurable envelope - renameable keys, optional wrapping, and swappable default/minimal/mobile/jsonapi presets.
  • Automatic data detection for models, collections, resources, paginators and DTOs.
  • Global metadata, hooks, events, macros and a template system for reusable responses.
  • Opt-in rate limiting middleware with a standard api()->tooManyRequests() envelope.
  • Opt-in audit logging of requests/responses to the database via a queued job, so logging never slows down a response.
  • Opt-in locale resolution middleware (Accept-Language header first, then a configurable user locale column).
  • Optional exception handler and response()->json() overrides, and testing assertion macros.
  • Fully backward compatible with the pre-2.0 BResponseSuccess/BResponseError/... API.

See the full documentation for configuration, usage examples and every extension point.

License

MIT.