์ด ํ๋ก์ ํธ๋ MySQL์ ํ์ตํ๋ฉฐ ๊ฐ๋ฐํ ๊ฒฐ๊ณผ๋ฌผ์
๋๋ค. ์ฌ์ฉํด ๋ณด์๊ณ , ์๋ฌ ์ฌํญ์ด๋ ๊ฐ์ ์ด ํ์ํ ๋ถ๋ถ์ด ์๋ค๋ฉด ๋๊ธ ๋๋ ๋ฉ์ผ๋ก ๋จ๊ฒจ์ฃผ์ธ์. ์ฌ๋ฌ๋ถ์ ํผ๋๋ฐฑ์ ํ๋ก์ ํธ ๋ฐ์ ์ ํฐ ๋์์ด ๋ฉ๋๋ค. ๐
์์ธํ ํ๋ก์ ํธ ๊ตฌ์ฑ์ GitHub๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์.
ํ์ฌ ๋ฌด๋ฃ ์๋ฒ๋ฅผ ์ฌ์ฉํ๊ณ ์์ด, ์ค์ 4์ ~ ์คํ 12์ ์ฌ์ด์ ์๋ฒ๊ฐ ๋์ํ์ง ์์ ์ ์์ต๋๋ค. ์ด ์ ์ํด ๋ถํ๋๋ฆฝ๋๋ค.
Korean Dummy JSON์ ํ๊ตญ์ด ๋๋ฏธ ๋ฐ์ดํฐ ์ ๊ณต์ ์ํด ๊ฐ๋ฐ๋ ํ๋ก์ ํธ์ ๋๋ค. ๊ฐ์ ์์ด ํธ๋ฆฌํ๊ณ ๊ฐํธํ๊ฒ ์ฌ์ฉ๊ฐ๋ฅํ๋ฉฐ, ํ๊ตญ์ด ๋ฐ์ดํฐ ์ ๊ณต์ผ๋ก ๋์ฑ ํ์ค๊ฐ ์๋ ๋ฐ์ดํฐ๋ฅผ ์ ๊ณต๋ฐ์ ์ ์์ต๋๋ค.
๋ก๊ทธ์ธ ๋ฐ ์ธ์ฆ/์ธ๊ฐ, ๋์ ๋๋ฏธ ์ด๋ฏธ์ง ์์ฑ ๊ธฐ๋ฅ์ ์ถ๊ฐ๋ก ์ ๊ณตํฉ๋๋ค.
์๋ ์ฌ์ดํธ์ ์ ์ํด์ ์ง์ ์ฌ์ฉํด๋ณด์ธ์.
Korean Dummy JSON
users, todos, posts, comments, books, reviews, auth, image ์ด 8๊ฐ์ resource๊ฐ ์ ๊ณต๋ฉ๋๋ค.
Resource | Information |
---|---|
/users | ์ ์ 20๋ช |
/posts | ๊ฒ์๋ฌผ 100๊ฐ |
/comments | ๋๊ธ 500๊ฐ |
/todos | ํ ์ผ 200๊ฐ |
/books | ์ฑ 100๊ฐ |
/reviews | ๋ฆฌ๋ทฐ 500๊ฐ |
/auth | ๋ก๊ทธ์ธ ๋ฐ ์ธ์ฆ/์ธ๊ฐ |
/image | ๋์ ๋๋ฏธ ์ด๋ฏธ์ง ์์ฑ |
1๋ฒ ๊ฒ์๋ฌผ์ ์กฐํํฉ๋๋ค.
fetch("https://koreandummyjson.site/api/posts/1")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error fetching data:', error));
๊ฒฐ๊ณผ
{
"message": "๊ฒ์๋ฌผ ์กฐํ ์ฑ๊ณต",
"post": {
"id": 1,
"title": "์์ธ์ ์จ๊ฒจ์ง ๋ช
์",
"content": "์์ธ์๋ ์ ์๋ ค์ง์ง ์์ ๋ฉ์ง ๋ช
์๊ฐ ๋ง๋ค. ์ต๊ทผ์ ๋ฐฉ๋ฌธํ ์์ ์นดํ์ ์กฐ์ฉํ ๊ณต์์ด ํนํ ๊ธฐ์ต์ ๋จ๋๋ค. ์ด๊ณณ์ ๋ณต์กํ ๋์๋ฅผ ๋ฒ์ด๋ ํํ๋ก์ด ์๊ฐ์ ๋ณด๋ผ ์ ์๋ ์๋ฒฝํ ์ฅ์์๋ค. ํนํ, ๋ฐ๋ปํ ์ฐจ์ ํจ๊ป ์ฐฝ๋ฐ์ ๋ฐ๋ผ๋ณด๋ฉฐ ์ฑ
์ ์ฝ๋ ์๊ฐ์ด ์ ๋ง ํ๋ณตํ๋ค.",
"imgUrl": "https://picsum.photos/id/1/300/300",
"createdAt": "2024-01-01T08:00:00.000Z",
"userId": 1
}
}
Pagination์ ํธ๋ฆฌํ๊ฒ ๊ตฌํํ ์ ์๋๋ก users, todos, posts, comments, books, reviews resources๋ Pagination API๋ฅผ ์ ๊ณตํฉ๋๋ค.
Endpoint
/{resoures}?page={page}&limit={limit}
์์ ์ฝ๋
๊ฒ์๋ฌผ ๋ชฉ๋ก์ 10๊ฐ์ฉ ํ์ด์ง๋ค์ด์
์ฒ๋ฆฌํ๋ฉฐ 1ํ์ด์ง๋ฅผ ์กฐํํฉ๋๋ค.
fetch("https://koreandummyjson.site/api/posts?page=1&limit=10")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error fetching data:', error));
๊ฒฐ๊ณผ
{
"message": "๊ฒ์๋ฌผ ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต",
"posts": [
{
"id": 1,
"title": "์์ธ์ ์จ๊ฒจ์ง ๋ช
์",
"content": "์์ธ์๋ ์ ์๋ ค์ง์ง ์์ ๋ฉ์ง ๋ช
์๊ฐ ๋ง๋ค. ์ต๊ทผ์ ๋ฐฉ๋ฌธํ ์์ ์นดํ์ ์กฐ์ฉํ ๊ณต์์ด ํนํ ๊ธฐ์ต์ ๋จ๋๋ค. ์ด๊ณณ์ ๋ณต์กํ ๋์๋ฅผ ๋ฒ์ด๋ ํํ๋ก์ด ์๊ฐ์ ๋ณด๋ผ ์ ์๋ ์๋ฒฝํ ์ฅ์์๋ค. ํนํ, ๋ฐ๋ปํ ์ฐจ์ ํจ๊ป ์ฐฝ๋ฐ์ ๋ฐ๋ผ๋ณด๋ฉฐ ์ฑ
์ ์ฝ๋ ์๊ฐ์ด ์ ๋ง ํ๋ณตํ๋ค.",
"imgUrl": "https://picsum.photos/id/1/300/300",
"createdAt": "2024-01-01T08:00:00.000Z",
"userId": 1
},
{
"id": 2,
"title": "์ฌ๋ฆ ๋ฐ๋ค์ ๋งค๋ ฅ",
"content": "์ฌ๋ฆ์ด ๋ค๊ฐ์ค๋ฉด์ ๋ฐ๋ค๋ฅผ ์ฐพ๋ ์ฌ๋๋ค๋ก ๊ฐ๋ํ๋ค. ๋ฐ๋ท๊ฐ์์์ ํ๋ฃจ๋ ์ธ์ ๋ ํน๋ณํ๋ค. ๋ชจ๋์ฌ์ฅ ์๋ฅผ ๊ฑท๊ณ , ํ๋ ์๋ฆฌ๋ฅผ ๋ค์ผ๋ฉฐ, ์์ํ ๋ฐ๋์ ๋ง๋ ์๊ฐ๋ค์ ์์ ์ ์๋ ๊ธฐ์ต์ด ๋๋ค. ํนํ, ์ผ๋ชฐ ๋ ๋ฐ๋ค๋ฅผ ๋ฐ๋ผ๋ณด๋ฉฐ ์ฐ์ ์ฌ์ง์ ๋๋ฌด ์๋ฆ๋ค์ ๋ค.",
"imgUrl": "https://picsum.photos/id/2/300/300",
"createdAt": "2024-01-03T09:00:00.000Z",
"userId": 2
},
...
],
"page": 1,
"limit": 10,
"hasNextPage": true
}
users, todos, posts, comments, books, reviews resources๋ Filtering API๋ฅผ ์ ๊ณตํฉ๋๋ค.
์์ ์ฝ๋
1๋ฒ ์ ์ ์ ๊ฒ์๋ฌผ์ ํํฐ๋งํฉ๋๋ค.
fetch("https://koreandummyjson.site/api/posts/?userId=1")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error fetching data:', error));
๊ฒฐ๊ณผ
{
"message": "๊ฒ์๋ฌผ ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต",
"posts": [
{
"id": 1,
"title": "์์ธ์ ์จ๊ฒจ์ง ๋ช
์",
"content": "์์ธ์๋ ์ ์๋ ค์ง์ง ์์ ๋ฉ์ง ๋ช
์๊ฐ ๋ง๋ค. ์ต๊ทผ์ ๋ฐฉ๋ฌธํ ์์ ์นดํ์ ์กฐ์ฉํ ๊ณต์์ด ํนํ ๊ธฐ์ต์ ๋จ๋๋ค. ์ด๊ณณ์ ๋ณต์กํ ๋์๋ฅผ ๋ฒ์ด๋ ํํ๋ก์ด ์๊ฐ์ ๋ณด๋ผ ์ ์๋ ์๋ฒฝํ ์ฅ์์๋ค. ํนํ, ๋ฐ๋ปํ ์ฐจ์ ํจ๊ป ์ฐฝ๋ฐ์ ๋ฐ๋ผ๋ณด๋ฉฐ ์ฑ
์ ์ฝ๋ ์๊ฐ์ด ์ ๋ง ํ๋ณตํ๋ค.",
"imgUrl": "https://picsum.photos/id/1/300/300",
"createdAt": "2024-01-01T08:00:00.000Z",
"userId": 1
},
{
"id": 21,
"title": "์ฌํ์ ์ถ์ต",
"content": "์ฌํ ์ค ์ดฌ์ํ ์ฌ์ง๋ค์ ๋ณด๋ฉฐ ๊ทธ๋์ ์ถ์ต์ด ์๋ก์๋ก ๋ ์ค๋ฅธ๋ค. ํนํ, ๊ทธ ์ง์ญ์ ์๋ฆ๋ค์ด ํ๊ฒฝ๊ณผ ํ์ง ์์๋ค์ ์์ ์ ์๋ ๊ฒฝํ์ด์๋ค. ์ฌํ์ ํตํด ์ป์ ์์คํ ๊ธฐ์ต๋ค์ ๊ณ์ ๊ฐ์งํ๊ณ ์ถ๋ค.",
"imgUrl": "https://picsum.photos/id/21/300/300",
"createdAt": "2024-04-11T12:00:00.000Z",
"userId": 1
},
{
"id": 41,
"title": "์์ธ์ ๋ช
์ ํ๋ฐฉ",
"content": "์์ธ์ ๋ค์ํ ๋ช
์๋ฅผ ํ๋ฐฉํ๋ ๊ฒ์ ์ธ์ ๋ ์ฆ๊ฑฐ์ด ์ผ์ด๋ค. ์ค๋์ ๋จ์ฐํ์๋ฅผ ๋ฐฉ๋ฌธํ์ฌ ์์ธ์ ์ ๊ฒฝ์ ๊ฐ์ํ๊ณ , ๋ง์๋ ์์์ ์ฆ๊ธฐ๋ฉฐ ์ข์ ์๊ฐ์ ๋ณด๋๋ค.",
"imgUrl": "https://picsum.photos/id/41/300/300",
"createdAt": "2024-07-05T16:00:00.000Z",
"userId": 1
},
{
"id": 61,
"title": "์์ธ์ ์ญ์ฌ ํ๋ฐฉ",
"content": "์์ธ์ ์ญ์ฌ๋ฅผ ํ๋ฐฉํ๋ ๊ฒ์ ํฅ๋ฏธ๋ก์ด ๊ฒฝํ์ด๋ค. ์ค๋์ ์์ธ์ ๊ณ ๊ถ์ ๋ฐฉ๋ฌธํ์ฌ ์ญ์ฌ์ ํ์ ์ ๋๊ผ๋ค. ๊ณผ๊ฑฐ์ ํ์ฌ๊ฐ ๋ง๋๋ ์ฅ์์์ ๋ง์ ๊ฒ์ ๋ฐฐ์ ๋ค.",
"imgUrl": "https://picsum.photos/id/61/300/300",
"createdAt": "2024-08-11T18:00:00.000Z",
"userId": 1
},
{
"id": 81,
"title": "๊ฐ์์ ํ๊ฒฝ",
"content": "๊ฐ์์ด ๊น์ด์ง๋ฉด์ ์์ฐ์ด ํฉ๊ธ๋น์ผ๋ก ๋ฌผ๋ค์ด ๊ฐ๋ค. ์ค๋์ ๊ณต์์์ ๋
ธ๋ ์ํ๋๋ฌด๋ฅผ ๋ณด๋ฉฐ ๊ฐ์์ ์ ์ทจ๋ฅผ ๋ง๋ฝํ๋ค. ์ด๋ฐ ์๊ฐ๋ค์ด ๊ฐ์์ ๋์ฑ ํน๋ณํ๊ฒ ๋ง๋ ๋ค.",
"imgUrl": "https://picsum.photos/id/81/300/300",
"createdAt": "2024-09-10T08:00:00.000Z",
"userId": 1
}
]
}
์ ๊ณตํ๋ Filtering API Endpoints๋ ์๋์ ๊ฐ์ต๋๋ค.
Endpoint | Method | Action |
---|---|---|
/todos?userId={userId} | GET | ์ ์ ๋ณ ํ ์ผ ๋ชฉ๋ก |
/comments?userId={userId} | GET | ์ ์ ๋ณ ๋๊ธ ๋ชฉ๋ก |
/comments?postId={postId} | GET | ๊ฒ์๋ฌผ๋ณ ๋๊ธ ๋ชฉ๋ก |
/reviews?bookId={bookId} | GET | ์ฑ ๋ณ ๋ฆฌ๋ทฐ ๋ชฉ๋ก |
/reviews?userId={userId} | GET | ์ ์ ๋ณ ๋ฆฌ๋ทฐ ๋ชฉ๋ก |
users, posts, books resources๋ ํ์์ ์ค์ฒฉ resource๋ฅผ ์ ๊ณตํฉ๋๋ค.
์์ ์ฝ๋
1๋ฒ ๊ฒ์๋ฌผ์ ๋๊ธ ๋ชฉ๋ก์ ์กฐํํฉ๋๋ค.
fetch("https://koreandummyjson.site/api/posts/1/comments")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error fetching data:', error));
๊ฒฐ๊ณผ
{
{
"message": "๊ฒ์๋ฌผ ๋๊ธ ๋ชฉ๋ก ์กฐํ ์ฑ๊ณต",
"comments": [
{
"id": 1,
"commentId": 1,
"content": "์ ๋ง ์ ์ตํ ๊ฒ์๋ฌผ์
๋๋ค!",
"createdAt": "2024-04-11T12:01:00.000Z"
},
{
"id": 1,
"commentId": 2,
"content": "์ข์ ์ ๋ณด ๊ฐ์ฌํฉ๋๋ค.",
"createdAt": "2024-04-11T12:03:00.000Z"
},
{
"id": 1,
"commentId": 3,
"content": "์ด ์ฃผ์ ์ ๋ํด ๋ ์๊ณ ์ถ์ด์.",
"createdAt": "2024-04-11T12:06:00.000Z"
},
{
"id": 1,
"commentId": 4,
"content": "๋์์ด ๋ง์ด ๋์์ด์.",
"createdAt": "2024-04-11T12:10:00.000Z"
},
{
"id": 1,
"commentId": 5,
"content": "์ ์ฝ์์ต๋๋ค.",
"createdAt": "2024-04-11T12:15:00.000Z"
}
]
}
}
์ ๊ณตํ๋ Nested API Endpoints ์๋์ ๊ฐ์ต๋๋ค.
Endpoint | Method | Action |
---|---|---|
/users/:id/todos | GET | ์ ์ ๋ณ ํ ์ผ ๋ชฉ๋ก ์กฐํ |
/users/:id/posts | GET | ์ ์ ๋ณ ๊ฒ์๋ฌผ ๋ชฉ๋ก ์กฐํ |
/users/:id/comment | GET | ์ ์ ๋ณ ๋๊ธ ๋ชฉ๋ก ์กฐํ |
/users/:id/reviews | GET | ์ ์ ๋ณ ๋ฆฌ๋ทฐ ๋ชฉ๋ก ์กฐํ |
/posts/:id/comments | GET | ๊ฒ์๋ฌผ๋ณ ๋๊ธ ๋ชฉ๋ก ์กฐํ |
/books/:id/reviews | GET | ์ฑ ๋ณ ๋ฆฌ๋ทฐ ๋ชฉ๋ก ์กฐํ |
๋์ ๋๋ฏธ ์ด๋ฏธ์ง๋ size, bgColor, textColor, ext, text๋ฅผ ๋ฐ์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ ์ ์์ต๋๋ค.
๋์ ๋๋ฏธ ์ด๋ฏธ์ง๋ ์ต๋ 2560 x 2560 size๋ก ์์ฑ ๊ฐ๋ฅํฉ๋๋ค.
์ด๋ฏธ์ง ํ์ฅ์ .jpeg, .jpg, .png, .svg๋ฅผ ์ง์ํฉ๋๋ค.
size๋ widthxhegiht ํน์ size(width=height) ํ์์ผ๋ก ์
๋ ฅํด์ผํฉ๋๋ค.
bgColor ๋ฐ textColor๋ HEX ์ฝ๋(# ์ ์ธ)๋ฅผ ์
๋ ฅํด์ผํฉ๋๋ค.
์ด๋ฏธ์ง ์ค์ ๊ธฐ๋ณธ๊ฐ
Endpoint
/image/:size/:bgColor/:text.{ext}/:textColor
์์ ์ฝ๋
ํฌ๊ธฐ๊ฐ 300x300 ์ด๊ณ , ๋ฐฐ๊ฒฝ ์์์ด #0000ff ํ
์คํธ๊ฐ 'Korean Dummy JSON' ํ
์คํธ ์์์ด #FFFFFF ํ์ฅ์๊ฐ .jpg์ธ ๋๋ฏธ ์ด๋ฏธ์ง๋ฅผ ์์ฑํฉ๋๋ค.
fetch("https://koreandummyjson.site/api/image/300/0000FF/Korean Dummy JSON.jpg/FFFFFF")
")
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error fetching data:', error));
๊ฒฐ๊ณผ
Endpoint | Method | Action |
---|---|---|
/users/:id | GET | ์ ์ ์กฐํ |
/users | GET | ์ ์ ๋ชฉ๋ก |
/users?page={page}&limit={limit} | GET | ์ ์ ๋ชฉ๋ก ํ์ด์ง |
/users/:id/todos | GET | ์ ์ ํ ์ผ ๋ชฉ๋ก ์กฐํ |
/users/:id/posts | GET | ์ ์ ๊ฒ์๋ฌผ ๋ชฉ๋ก ์กฐํ |
/users/:id/comments | GET | ์ ์ ๋๊ธ ๋ชฉ๋ก ์กฐํ |
/users/:id/books | GET | ์ ์ ์ฑ ๋ชฉ๋ก ์กฐํ |
/users/:id/reviews | GET | ์ ์ ๋ฆฌ๋ทฐ ๋ชฉ๋ก ์กฐํ |
/users | POST | ์ ์ ์์ฑ |
/users/:id | PUT | ์ ์ ์์ |
/users/:id | PATCH | ์ ์ ์์ |
/users/:id | DELETE | ์ ์ ์ญ์ |
/todos/:id | GET | ํ ์ผ ์กฐํ |
/todos | GET | ํ ์ผ ๋ชฉ๋ก |
/todos?userId={userId} | GET | ์ ์ ํ ์ผ ๋ชฉ๋ก ํํฐ๋ง |
/todos?page={page}&limit={limit} | GET | ํ ์ผ ๋ชฉ๋ก ํ์ด์ง |
/todos | POST | ํ ์ผ ์์ฑ |
/todos/:id | PUT | ํ ์ผ ์์ |
/todos/:id | PATCH | ํ ์ผ ์์ |
/todos/:id | DELETE | ํ ์ผ ์ญ์ |
/posts/:id | GET | ๊ฒ์๋ฌผ ์กฐํ |
/posts | GET | ๊ฒ์๋ฌผ ๋ชฉ๋ก |
/posts?page={page}&limit={limit} | GET | ๊ฒ์๋ฌผ ๋ชฉ๋ก ํ์ด์ง |
/posts/:id/comments | GET | ๊ฒ์๋ฌผ ๋๊ธ ๋ชฉ๋ก ์กฐํ |
/posts?userId={userId} | GET | ์ ์ ๊ฒ์๋ฌผ ๋ชฉ๋ก ํํฐ๋ง |
/posts | POST | ๊ฒ์๋ฌผ ์์ฑ |
/posts/:id | PUT | ๊ฒ์๋ฌผ ์์ |
/posts/:id | PATCH | ๊ฒ์๋ฌผ ์์ |
/posts/:id | DELETE | ๊ฒ์๋ฌผ ์ญ์ |
/comments/:id | GET | ๋๊ธ ์กฐํ |
/comments | GET | ๋๊ธ ๋ชฉ๋ก |
/comments?page={page}&limit={limit} | GET | ๋๊ธ ๋ชฉ๋ก ํ์ด์ง |
/comments?userId={userId} | GET | ์ ์ ๋๊ธ ๋ชฉ๋ก ํํฐ๋ง |
/comments?postId={postId} | GET | ๊ฒ์๋ฌผ ๋๊ธ ๋ชฉ๋ก ํํฐ๋ง |
/comments | POST | ๋๊ธ ์์ฑ |
/comments/:id | PUT | ๋๊ธ ์์ |
/comments/:id | PATCH | ๋๊ธ ์์ |
/comments/:id | DELETE | ๋๊ธ ์ญ์ |
/books/:id | GET | ์ฑ ์กฐํ |
/books | GET | ์ฑ ๋ชฉ๋ก |
/books?page={page}&limit={limit} | GET | ์ฑ ๋ชฉ๋ก ํ์ด์ง |
/books/:id/reviews | GET | ์ฑ ๋ฆฌ๋ทฐ ๋ชฉ๋ก ์กฐํ |
/books | POST | ์ฑ ์์ฑ |
/books/:id | PUT | ์ฑ ์์ |
/books/:id | PATCH | ์ฑ ์์ |
/books/:id | DELETE | ์ฑ ์ญ์ |
/reviews/:id | GET | ๋ฆฌ๋ทฐ ์กฐํ |
/reviews | GET | ๋ฆฌ๋ทฐ ๋ชฉ๋ก |
/reviews?page={page}&limit={limit} | GET | ๋ฆฌ๋ทฐ ๋ชฉ๋ก ํ์ด์ง |
/reviews?userId={userId} | GET | ์ ์ ๋ฆฌ๋ทฐ ํํฐ๋ง |
/reviews?bookId={bookId} | GET | ์ฑ ๋ฆฌ๋ทฐ ํํฐ๋ง |
/reviews | POST | ๋ฆฌ๋ทฐ ์์ฑ |
/reviews/:id | PUT | ๋ฆฌ๋ทฐ ์์ |
/reviews/:id | PATCH | ๋ฆฌ๋ทฐ ์์ |
/reviews/:id | DELETE | ๋ฆฌ๋ทฐ ์ญ์ |
/auth/login | POST | ๋ก๊ทธ์ธ |
/auth/user | GET | ์ ์ ์กฐํ |
/auth/refreshToken | GET | ํ ํฐ ์ฌ๋ฐ๊ธ |
/image/:size/:bgColor/:text.{ext}/:textColor | GET | ๋์ ๋๋ฏธ ์ด๋ฏธ์ง ์์ฑ |