PHPackages                             mpstr24/laravel-api-responses - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. mpstr24/laravel-api-responses

ActivePackage[HTTP &amp; Networking](/categories/http)

mpstr24/laravel-api-responses
=============================

Laravel package for formatted API responses.

v1.1.0(8mo ago)01.1k↓50%MITPHPPHP ^8.0CI passing

Since Mar 10Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/MPSTR24/laravel-api-responses)[ Packagist](https://packagist.org/packages/mpstr24/laravel-api-responses)[ Docs](https://github.com/MPSTR24/laravel-api-responses)[ RSS](/packages/mpstr24-laravel-api-responses/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Laravel API Responses
=====================

[](#laravel-api-responses)

This package provides API response functions via a trait to help improve consistency of API response codes across your projects.

[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/e6b7b186863c9af9f728db8107b03da77d2e17f1be57bd86043069ae116f8ddf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7073747232342f6c61726176656c2d6170692d726573706f6e7365732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e)](https://camo.githubusercontent.com/e6b7b186863c9af9f728db8107b03da77d2e17f1be57bd86043069ae116f8ddf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d7073747232342f6c61726176656c2d6170692d726573706f6e7365732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e)[![Packagist Version](https://camo.githubusercontent.com/7004b1f436cb17dc96ec4af71edc7cfcb911eb878848ac3403fd71a98ffcc366/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7073747232342f6c61726176656c2d6170692d726573706f6e736573)](https://camo.githubusercontent.com/7004b1f436cb17dc96ec4af71edc7cfcb911eb878848ac3403fd71a98ffcc366/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7073747232342f6c61726176656c2d6170692d726573706f6e736573)[![Packagist Downloads](https://camo.githubusercontent.com/ebbb5d5d8fad6e411afa71a600f4021479aaf01f0dd2ad679e66348eddbd272a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7073747232342f6c61726176656c2d6170692d726573706f6e736573)](https://camo.githubusercontent.com/ebbb5d5d8fad6e411afa71a600f4021479aaf01f0dd2ad679e66348eddbd272a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d7073747232342f6c61726176656c2d6170692d726573706f6e736573)

Features
--------

[](#features)

- Pre-made functions of the most common API responses.

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require mpstr24/laravel-api-responses
```

Usage/Examples
--------------

[](#usageexamples)

First add the trait to your controller.

```
use ApiResponseTrait;
```

All methods, except from "No Content" allow for a message and data to be returned. Custom messages also allow you to choose the status code.

Examples of each below.

### Success - 200

[](#success---200)

```
public function success()
{
  return $this->apiSuccess();
}
```

### Created - 201

[](#created---201)

```
public function created()
{
    return $this->apiCreated();
}
```

### Accepted - 202

[](#accepted---202)

```
public function accepted()
{
    return $this->apiAccepted();
}
```

### No Content - 204

[](#no-content---204)

```
public function noContent()
{
    return $this->apiNoContent();
}
```

### Bad Request - 400

[](#bad-request---400)

```
public function badRequest()
{
    return $this->apiBadRequest();
}
```

### Unauthorized - 401

[](#unauthorized---401)

```
public function unauthorized()
{
    return $this->apiUnauthorized();
}
```

### Forbidden - 403

[](#forbidden---403)

```
public function forbidden()
{
    return $this->apiForbidden();
}
```

### Not Found - 404

[](#not-found---404)

```
public function notFound()
{
    return $this->apiNotFound();
}
```

### Teapot - 418

[](#teapot---418)

```
public function teapot()
{
    return $this->apiTeapot();
}
```

### Unprocessable - 422

[](#unprocessable---422)

```
public function unprocessable()
{
    return $this->apiUnprocessable();
}
```

### Too Many Requests - 429

[](#too-many-requests---429)

```
public function tooManyRequests()
{
    return $this->apiTooManyRequests();
}
```

### Server Error - 500

[](#server-error---500)

```
public function serverError()
{
    return $this->apiInternalServerError();
}
```

### Custom response

[](#custom-response)

```
public function apiCustomResponse()
{
    return $this->apiCustom('Custom', null, 201);
}
```

Roadmap
-------

[](#roadmap)

- Support for resources
- Expand into more helpful API features
- Larastan goals
    - 5
    - 6
    - 7
    - 8
    - 9

License
-------

[](#license)

[MIT](https://choosealicense.com/licenses/mit/)

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance65

Regular maintenance activity

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~183 days

Total

2

Last Release

240d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/773463d85604eb752853b3c3a25480bbadba2eb6215eb22669497192b2cb1d21?d=identicon)[MPSTR](/maintainers/MPSTR)

---

Top Contributors

[![MPSTR24](https://avatars.githubusercontent.com/u/74561948?v=4)](https://github.com/MPSTR24 "MPSTR24 (13 commits)")

---

Tags

apiapi-responselaravellaravel-packagehttpapilaravelpackageresponses

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mpstr24-laravel-api-responses/health.svg)

```
[![Health](https://phpackages.com/badges/mpstr24-laravel-api-responses/health.svg)](https://phpackages.com/packages/mpstr24-laravel-api-responses)
```

###  Alternatives

[pusher/pusher-http-laravel

\[DEPRECATED\] A Pusher bridge for Laravel

400509.0k3](/packages/pusher-pusher-http-laravel)[vinelab/http

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

59300.2k11](/packages/vinelab-http)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

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