This project is a web application that provides various APIs for managing blog posts.
To get started with the project, follow these steps:
- Clone the repository:
- Change into the project directory:
- Install the dependencies using Composer:
- Set up the database by creating a new database and configuring the
.env
file with your database credentials: - Generate the application key:
- Migrate the database:
- Optionally, seed the database with sample data:
git clone https://github.com/bimprakosoo/api-blog.git
cd api-blog
composer install
cp .env.example .env
Update the .env
file with your database information.
php artisan key:generate
php artisan migrate
php artisan db:seed
The following APIs are available in this project:
- POST /api/register: User login. It accepts the
name
,email
andpassword
parameters and returns a JSON response telling user registered succesfully. - POST /api/login: User login. It accepts the
email
andpassword
parameters and returns a JSON response containing the access token upon successful authentication. - POST /api/logout: User logout. It requires the
Authorization
header with the access token to invalidate the token and perform the logout operation. - GET /api/post: Get all blog posts. It returns a JSON response containing a list of all blog posts.
- GET /api/post/{id}: Get a specific blog post by ID. It accepts the
id
parameter in the URL and returns a JSON response with the details of the blog post. - POST /api/post/add: Create a new blog post. It accepts the
title
,content
,category_id
, andtags_id
parameters in the request body and creates a new blog post. - PUT /api/posts/edit/{id}: Update a blog post. It accepts the
id
parameter in the URL and thetitle
,content
,category_id
, andtags_id
parameters in the request body to update the specified blog post. - DELETE /api/post/delete/{id}: Delete a blog post. It accepts the
id
parameter in the URL to delete the specified blog post. - POST /api/category/add: Create a new category. It accepts the
name
parameter in the request body and creates a new category. - GET /api/category: Get all categories. It returns a JSON response containing a list of all categories.
- GET /api/category/{id}: Get a specific category by ID. It accepts the
id
parameter in the URL and returns a JSON response with the details of the category. - PUT /api/category/edit/{id}: Update a category. It accepts the
id
parameter in the URL and thename
parameters in the request body to update the specified category. - DELETE /api/category/delete/{id}: Delete a category. It accepts the
id
parameter in the URL to delete the specified category. - POST /api/tag/add: Create a new tag. It accepts the
name
parameter in the request body and creates a new tag. - GET /api/tag: Get all tags. It returns a JSON response containing a list of all categories.
- GET /api/tag/{id}: Get a specific tag by ID. It accepts the
id
parameter in the URL and returns a JSON response with the details of the tag. - PUT /api/tag/edit/{id}: Update a tag. It accepts the
id
parameter in the URL and thename
parameters in the request body to update the specified tag. - DELETE /api/tag/delete/{id}: Delete a tag. It accepts the
id
parameter in the URL to delete the specified tag. - POST /api/post/comments: Create a new comment. It accepts the
post_id
andcontent
parameters in the request body to create a new comment for a specific blog post.
These APIs can be accessed using HTTP requests with the appropriate headers and parameters.
This project is licensed under the MIT License.