[ Frontend ]

[Mock Rest API] jsonplaceholder 소개 (REST API 테스트용 가상 데이터 제공 사이트)

HSRyuuu 2024. 8. 9. 23:45
해당 사이트에 정말 쉽고 편하게 설명되어 있기 때문에, 기록용으로 쓰는 글입니다.
프런트엔드 쪽은 처음 공부해 보는데 정말 편리한 사이트들이 많네요...
(이게 말로만 듣던 javascript 생태계..?)

 

jsonplaceholder.typicode.com


https://jsonplaceholder.typicode.com/
 

JSONPlaceholder - Free Fake REST API

{JSON} Placeholder Free fake and reliable API for testing and prototyping. Powered by JSON Server + LowDB. Serving ~3 billion requests each month.

jsonplaceholder.typicode.com

 

 

위의 사이트는 가짜 데이터(Json)를 제공해 주는 사이트이다.

User, Post, Comment, Album, Photo, todolist 6종의 많이 사용되는 도메인의 데이터를 제공한다.

 

데이터 종류, 개수

  • 10명의 User
  • 100개의 Post (userId 당 10개씩)
  • 500개의 Comment(postId 당 5개씩)
  • 100개의 Album(userId 당 10개씩)
  • 5000개의 Photo(albumId 당 50개씩)
  • 200개의 todo(userId 당 20개씩)

ERD를 그려보면 대략 아래와 같다.

여기서 User는 우측과 같이 address, company 데이터가 객체 형태이다.

데이터 활용

http, https 요청이 둘 다 가능하며, 각 데이터에 대한 GET / POST / PUT / PATCH / DELETE 요청이 전부 가능하다고 한다.

GET /posts
GET /posts/1
GET /posts/1/comments
GET /comments?postId=1
POST /posts
PUT /posts/1
PATCH /posts/1
DELETE /posts/1

 

https://jsonplaceholder.typicode.com/{uri-pattern}?{queryParams}

위와 같은 url로 요청을 보내면 응답이 잘 오는 것을 확인할 수 있다.

반응형