This repository contains a simple demo API built with Laravel.
- Clone the repository with git clone
- Copy .env.example file to .env and edit database credentials there
- Run composer install
- Run php artisan key:generate
- That's it - people can register and take quizzes!
The API only has the following endpoint which is the /api/
. The endpoint works with the HTTP verbs: POST
, GET
POST
/login- INPUT:
email: [email protected]
password: awonusi11
- HTTP Status:
201: created
- JSON data
{
"status": "success",
"user": {
"id": 1,
"name": "awonusi",
"email": "[email protected]",
"api_token": "2qi8yfZjFUHJVZ4VtDRXjEdDNexX6B5OY4peN9u5nN4fR5k8sL",
"created_at": "2018-01-31 12:03:17",
"updated_at": "2018-01-31 14:39:45",
"image": "null"
}
}
POST
/register- INPUT:
name: awonusi1
email: [email protected]
password: awonusi11
- HTTP Status:
201: created
- JSON data
{
"status": "success",
"user": {
"name": "awonusi1",
"email": "[email protected]",
"api_token": "fCb6MJLBLX7UwLDCPh963jjEp6FItLFFohvCUaxL19EueXcDMW",
"updated_at": "2018-01-31 14:41:50",
"created_at": "2018-01-31 14:41:50",
"id": 2
}
}
GET
/logout
- HTTP Status:
201: created
- JSON data
{
"status": "success",
"message": "You are now logged out"
}
POST
/profile- INPUT:
email: [email protected]
image: image/adsadzfdsf.jpg
- HTTP Status:
201: created
- JSON data
{
"status": "success",
"message": "Profile Pix Success"
}
GET
/allquestions
- HTTP Status:
201: created
- JSON data
{
"status": "success",
"questions": [
{
"id": 1,
"body": "Who is the President of Nigeria",
"answer": "Buhari",
"option1": "buhari",
"option2": "yaradua",
"option3": "obasanjo"
},
{
"id": 2,
"body": "Nigeria flag",
"answer": "green white green",
"option1": "green white green",
"option2": "yellow white yellow",
"option3": "red white red"
}
]
}
POST
/result- INPUT:
user_id: 1
result: 50
- HTTP Status:
201: created
- JSON data
{
"status": "success",
"message": "Result stored"
}
Basically, feel free to use and re-use any way you want.
Awonusi Olajide - Software Developer at Instantpickup