parent
d51f34875c
commit
53d46dd1f7
1 changed files with 206 additions and 0 deletions
@ -0,0 +1,206 @@ |
|||||||
|
--- |
||||||
|
title: 'Blogging Platform API' |
||||||
|
description: 'Build a RESTful API for a personal blogging platform' |
||||||
|
isNew: false |
||||||
|
sort: 6 |
||||||
|
difficulty: 'beginner' |
||||||
|
nature: 'API' |
||||||
|
skills: |
||||||
|
- 'Programming Language' |
||||||
|
- 'CRUD' |
||||||
|
- 'RESTful API' |
||||||
|
- 'Database' |
||||||
|
seo: |
||||||
|
title: 'Blogging Platform API Project Idea' |
||||||
|
description: 'Build a RESTful API for a personal blogging platform. Users can create, read, update, and delete blog posts using the API.' |
||||||
|
keywords: |
||||||
|
- 'blogging platform api' |
||||||
|
- 'backend project idea' |
||||||
|
roadmapIds: |
||||||
|
- 'backend' |
||||||
|
--- |
||||||
|
|
||||||
|
You are required to create a simple RESTful API with basic CRUD operations for a personal blogging platform. CRUD stands for Create, Read, Update, and Delete. The goals of this project are to help you: |
||||||
|
|
||||||
|
- Understand what the RESTful APIs are including best practices and conventions |
||||||
|
- Learn how to create a RESTful API |
||||||
|
- Learn about common HTTP methods like GET, POST, PUT, PATCH, DELETE |
||||||
|
- Learn about status codes and error handling in APIs |
||||||
|
- Learn how to perform CRUD operations using an API |
||||||
|
- Learn how to work with databases |
||||||
|
|
||||||
|
## Constraints |
||||||
|
|
||||||
|
- You can use any programming language and framework of your choice |
||||||
|
- You can use any database of your choice (SQL or NoSQL) |
||||||
|
- You can use any libraries for validation and error handling |
||||||
|
- There is no frontend required for this project since you are building an API |
||||||
|
- You can use any API testing tool like Postman, Insomnia, or cURL to test your API |
||||||
|
|
||||||
|
## Requirements |
||||||
|
|
||||||
|
Each blog post should have the following fields: |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"title": "My First Blog Post", |
||||||
|
"content": "This is the content of my first blog post.", |
||||||
|
"category": "Technology", |
||||||
|
"tags": ["Tech", "Programming"] |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
The API should have the following endpoints: |
||||||
|
|
||||||
|
### Create Blog Post |
||||||
|
|
||||||
|
Create a new blog post using the `POST` method |
||||||
|
|
||||||
|
```plaintext |
||||||
|
POST /posts |
||||||
|
{ |
||||||
|
"title": "My First Blog Post", |
||||||
|
"content": "This is the content of my first blog post.", |
||||||
|
"category": "Technology", |
||||||
|
"tags": ["Tech", "Programming"] |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
The endpoint should validate the request body and return a `201 Created` status code with the newly created blog post i.e. |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"id": 1, |
||||||
|
"title": "My First Blog Post", |
||||||
|
"content": "This is the content of my first blog post.", |
||||||
|
"category": "Technology", |
||||||
|
"tags": ["Tech", "Programming"], |
||||||
|
"createdAt": "2021-09-01T12:00:00Z", |
||||||
|
"updatedAt": "2021-09-01T12:00:00Z" |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
or a `400 Bad Request` status code with error messages in case of validation errors. |
||||||
|
|
||||||
|
## Update Blog Post |
||||||
|
|
||||||
|
Update an existing blog post using the `PUT` method |
||||||
|
|
||||||
|
```plaintext |
||||||
|
PUT /posts/1 |
||||||
|
{ |
||||||
|
"title": "My Updated Blog Post", |
||||||
|
"content": "This is the updated content of my first blog post.", |
||||||
|
"category": "Technology", |
||||||
|
"tags": ["Tech", "Programming"] |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
The endpoint should validate the request body and return a `200 OK` status code with the updated blog post i.e. |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"id": 1, |
||||||
|
"title": "My Updated Blog Post", |
||||||
|
"content": "This is the updated content of my first blog post.", |
||||||
|
"category": "Technology", |
||||||
|
"tags": ["Tech", "Programming"], |
||||||
|
"createdAt": "2021-09-01T12:00:00Z", |
||||||
|
"updatedAt": "2021-09-01T12:30:00Z" |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
or a `400 Bad Request` status code with error messages in case of validation errors. It should return a `404 Not Found` status code if the blog post was not found. |
||||||
|
|
||||||
|
### Delete Blog Post |
||||||
|
|
||||||
|
Delete an existing blog post using the `DELETE` method |
||||||
|
|
||||||
|
```plaintext |
||||||
|
DELETE /posts/1 |
||||||
|
``` |
||||||
|
|
||||||
|
The endpoint should return a `204 No Content` status code if the blog post was successfully deleted or a `404 Not Found` status code if the blog post was not found. |
||||||
|
|
||||||
|
### Get Blog Post |
||||||
|
|
||||||
|
Get a single blog post using the `GET` method |
||||||
|
|
||||||
|
```plaintext |
||||||
|
GET /posts/1 |
||||||
|
``` |
||||||
|
|
||||||
|
The endpoint should return a `200 OK` status code with the blog post i.e. |
||||||
|
|
||||||
|
```json |
||||||
|
{ |
||||||
|
"id": 1, |
||||||
|
"title": "My First Blog Post", |
||||||
|
"content": "This is the content of my first blog post.", |
||||||
|
"category": "Technology", |
||||||
|
"tags": ["Tech", "Programming"], |
||||||
|
"createdAt": "2021-09-01T12:00:00Z", |
||||||
|
"updatedAt": "2021-09-01T12:00:00Z" |
||||||
|
} |
||||||
|
``` |
||||||
|
|
||||||
|
or a `404 Not Found` status code if the blog post was not found. |
||||||
|
|
||||||
|
### Get All Blog Posts |
||||||
|
|
||||||
|
Get all blog posts using the `GET` method |
||||||
|
|
||||||
|
```plaintext |
||||||
|
GET /posts |
||||||
|
``` |
||||||
|
|
||||||
|
The endpoint should return a `200 OK` status code with an array of blog posts i.e. |
||||||
|
|
||||||
|
```json |
||||||
|
[ |
||||||
|
{ |
||||||
|
"id": 1, |
||||||
|
"title": "My First Blog Post", |
||||||
|
"content": "This is the content of my first blog post.", |
||||||
|
"category": "Technology", |
||||||
|
"tags": ["Tech", "Programming"], |
||||||
|
"createdAt": "2021-09-01T12:00:00Z", |
||||||
|
"updatedAt": "2021-09-01T12:00:00Z" |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": 2, |
||||||
|
"title": "My Second Blog Post", |
||||||
|
"content": "This is the content of my second blog post.", |
||||||
|
"category": "Technology", |
||||||
|
"tags": ["Tech", "Programming"], |
||||||
|
"createdAt": "2021-09-01T12:30:00Z", |
||||||
|
"updatedAt": "2021-09-01T12:30:00Z" |
||||||
|
} |
||||||
|
] |
||||||
|
``` |
||||||
|
|
||||||
|
You don't have to implement pagination, authentication or authorization for this project. You can focus on the core functionality of the API. |
||||||
|
|
||||||
|
While retrieving posts, user can also filter posts by a search term. You should do a wildcard search on the title, content or category fields of the blog posts. For example: |
||||||
|
|
||||||
|
```plaintext |
||||||
|
GET /posts?term=tech |
||||||
|
``` |
||||||
|
|
||||||
|
This should return all blog posts that have the term "tech" in their title, content or category. You can use a simple SQL query if you are using a SQL database or a similar query for a NoSQL database. |
||||||
|
|
||||||
|
<hr /> |
||||||
|
|
||||||
|
## Tech Stack |
||||||
|
|
||||||
|
Feel free to use any programming language, framework, and database of your choice for this project. Here are some suggestions: |
||||||
|
|
||||||
|
- If you are using JavaScript, you can use Node.js with Express.js |
||||||
|
- If you are using Python, you can use Flask or Django |
||||||
|
- If you are using Java, you can use Spring Boot |
||||||
|
- If you are using Ruby, you can use Ruby on Rails |
||||||
|
|
||||||
|
For databases, you can use: |
||||||
|
|
||||||
|
- MySQL if you are using SQL |
||||||
|
- MongoDB if you are using NoSQL |
Loading…
Reference in new issue