티스토리 뷰

JSONPlaceholder

pilot376 2020. 7. 28. 08:58

JSONPlaceholder는 더미 데이터가 필요할 때 사용할 수있는 무료 온라인 REST API이다. 각종 테스트 시 유용하게 사용할 수 있다. (URL : https://jsonplaceholder.typicode.com/)

 

예제

아래의 샘플 코드를 실행시키면 (jquery ajax)

$.ajax({
    url: 'https://jsonplaceholder.typicode.com/todos/1',
    success: function (data) {
      console.log(data)
    }
  })

 

아래의 response 값을 받을 수 있다.

{
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false
}

요청 시 http, https 모두 사용할 수 있다.

 

Resources

사용할 수 있는 Resources는 아래와 같다.

  • /posts 100 posts
  • /comments 500 comments
  • /albums 100 albums
  • /photos 5000 photos
  • /todos 200 todos
  • /users 10 users

 

Routes

지원되는 메소드는 아래와 같다.

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

 

더 자세한 내용은 https://jsonplaceholder.typicode.com/guide.html 에서 확인 가능

댓글