This is an API for managing quotes. It is built using Laravel 10.10 and PHP 8.1. It uses a Sqlite database for storage.
- Clone the repository
- Run
composer install
- Run
php artisan migrate
- Run
php artisan serve
- The API is now available at http://localhost:8000
The API has the following endpoints:
Returns a quote for non-authenticated user
clear cache and returns a quote for non-authenticated user
Returns quotes for authenticated user
Returns quotes for authenticated user
clear cache and returns quotes for authenticated user
Returns five random quotes for non-authenticated user and authenticated user
clear cache and returns five random quotes for non-authenticated user and authenticated user
Returns favorite quotes for authenticated user
Save a quote as favorite for authenticated user
Returns a report of the all user and the favorite quotes
Get specific favorite quote for authenticated user
Delete specific favorite quote for authenticated user
Run php artisan test
to run the tests
The API uses caching to improve performance. It can also be cleared manually by calling the /api/today/new
endpoint for non-authenticated user and /api/secure-quotes/new
for authenticated user.
The API uses Laravel Sanctum for authentication. To authenticate, send a POST request to /api/login
with the following body:
{
"email": "[email protected]",
"password": "password"
}
The API will return a token that can be used to authenticate future requests. To authenticate future requests, add the following header to the request:
{
"user": {
"id": 1,
"name": "Test User",
"email": "[email protected]",
"created_at": "2021-10-31T15:00:00.000000Z",
"updated_at": "2021-10-31T15:00:00.000000Z"
},
"token": "nnu5PxuJ1xplBbdJrtNM2Q==0s5CpRd6HH0ba0Qm"
}
- Code Repository
- Datastore
- Datastore Initialization
- Cache
- API Authentication
- Api Registration for users
- Quote of the Day
- Five Random QUotes
- Ten Secure Quotes
- Favorite Quotes
- Report of Favorite Quotes
- REST API for Five Random Quotes
- REST API for Ten Secure Quotes
- Online API Test
- Console/Shell Command for Five Random Quotes
- PHP Automated Testing
- Documentation