2017 © Pedro Peláez
 

library apibase

Adds CRUD functionality through a RESTful API for Laravel

image

thirdsteplabs/apibase

Adds CRUD functionality through a RESTful API for Laravel

  • Sunday, January 17, 2016
  • by beaulm
  • Repository
  • 1 Watchers
  • 4 Stars
  • 159 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

RESTful CRUD API

All calls to the API will start with /api/v1/
All responses will be in JSON
If any response other than 200 is given, the JSON will be an array with a code and message element, (*1)

Login:

  • URL: /api/v1/login
  • Method: ANY
  • Params: username, password OR token
  • Response: token
    *All subsequent requests will require that token.

Example: /api/v1/login?username=3333334444&password=fake
Ex Return: {"data":{"token":"12d3ff","user":{"id":2,"username":"3333334444","name":"Beau Lynn-Miller","phone":"3333334444","email":"beaulm@gmail.com","created_at":"2014-10-17 10:16:58","updated_at":"2014-10-17 10:17:00","deleted_at":null,"last_offered":null}},"timestamp":"2014-10-17 10:57:05","hashes":{"gpsConfig":"422962d8","vehicles":"86e45d7c","towingCompanies":"011500b9","states":"738ee935"}}, (*2)

Get All:

  • URL: /api/v1/{object}
  • Method: GET
  • Params: token
  • Response: array of object data

Example: /api/v1/user?token=12d3ff
Ex Return: [{"id":1,"name":"Fakey McFakerson","email":"fake@fake.com"},{"id":2,"name":"Foo McBarenson","email":"foo@bar.com"}], (*3)

Get Specific:

  • URL: /api/v1/{object}/{id}
  • Method: GET
  • Params: token
  • Response: object data

Example: /api/v1/user/2?token=12d3ff
Ex Return: {"id":2,"name":"Foo McBarenson","email":"foo@bar.com"}, (*4)

Create Object:

  • URL: /api/v1/{object}
  • Method: POST
  • Params: token, fillabe parameters defined in model
  • Response: object data

Example: /api/v1/user?name=Testey&password=test&email=test@test.com&phone=5551234123&token=12d3ff
Ex Return: {"id":3,"name":"Testey","email":"test@test.com","phone":"5551234123"}, (*5)

Update Object:

  • URL: /api/v1/{object}/{id}
  • Method: PUT
  • Params: token, fillabe parameters defined in model
  • Response: object data

Example: /api/v1/user/2?phone=5557777777&token=12d3ff
Ex Return: {"id":2,"name":"Foo McBarenson","email":"foo@bar.com","phone":"5557777777"}, (*6)

Delete Object:

  • URL: /api/v1/{object}/{id}
  • Method: DELETE
  • Params: token
  • Response: array of remaining objects

Example: /api/v1/user/1
Ex Return: [{"id":2,"name":"Foo McBarenson","email":"foo@bar.com","phone":"5557777777"},{"id":3,"name":"Testey","email":"test@test.com","phone":"5551234123"}], (*7)

Logout:

  • URL: /api/v1/logout
  • Method: ANY
  • Params: token
  • Response: JSON with message

Example: /api/v1/logout?token=12d3ff
Ex Return: {"message":"Logout successful"}, (*8)

Error:

Making a call without a token will result in an error:, (*9)

Example: /api/v1/user
Ex Return: {"code":401,"message":"You do not have access to view this web page"}, (*10)

The Versions

17/01 2016

dev-master

9999999-dev

Adds CRUD functionality through a RESTful API for Laravel

  Sources   Download

The Requires

 

by Beau Lynn-Miller

laravel