Skip to content

This package aims to help you standardize all your API responses in a simple and structured way.

License

Notifications You must be signed in to change notification settings

kodepandai/laravel-api-response

Repository files navigation

Laravel API Response v2

A helper package to return JSON Api Response in structured way.

By default, the structure of the response will look like this:

{
  "success": true, // it was successfull or not
  "title": "Users", // the title/headline/section 
  "message": "Active users only", // the message/description/highlight
  "data": { // if it was successfull
    // profile..
    // users..
    // products..
    // etc..
  },
  "errors": { // if it was not successfull
    // validation errors..
    // any other errors..
  }
}

Example:

{
  "success": true,
  "title": "Users",
  "message": "Succesfully create a user",
  "data": {
    "id": 1,
    "name": "John Doe",
    "address": "4th Semarang Raya",
  },
}

Install