Skip to content

Latest commit

 

History

History
46 lines (46 loc) · 1.97 KB

README.md

File metadata and controls

46 lines (46 loc) · 1.97 KB

sampleAPI

Sample PHP API based on Laravel Framework

Live API DEMO

You can give it a try at: https://jessie365/api/{command}

Commands Supported

1. Register user:
CREATE POST Request to URL: hostname/api/users
The body of the request must contain these fields in JSON format:

  • name
  • email
  • password
  • password_confirmation
2. Log in | Authenticate user:
CREATE POST Request to URL: hostname/api/auth
The body of the request must contain these fields in JSON format:
  • email
  • password
RETURNS: access token for executing commands that needs authentication when valid credentials are entered.

3. Create Post:
CREATE POST Request to URL: hostname/api/posts
The body of the request must contain these fields in JSON format:
  • title
  • body
*Creating Post requires authenticated user: Provide the token in the request header as follows:
name: 'Authorization'; value: 'Bearer {TOKEN_HERE}'

4. Create Comment:
CREATE POST Request to URL: hostname/api/posts/{postId}/comments
The body of the request must contain these fields in JSON format:
  • body
*Creating Post requires authenticated user: Provide the token in the request header as follows:
name: 'Authorization'; value: 'Bearer {TOKEN_HERE}'

5. Show list of posts:
CREATE GET Request to URL: hostname/api/posts
RETURNS: List of posts ordered by creation date DESCENDING
PARAMS: Use hostname/api/posts/?orderBy=comments to get a list of posts ordered by most comments