GET /posts/{id}/comments

Get Post Comments

Retrieve all comments for a specific blog post by post ID including commenter details and comment body

Overview

Retrieves all comments associated with a specific blog post.

Path Parameters

Path Parameters

id required
integer

The ID of the post to get comments for

Response

Returns an array of comment objects.

id integer

Unique identifier for the comment

postId integer

ID of the post this comment belongs to

name string

Title or subject of the comment

email string

Email address of the commenter

body string

Content of the comment

Get Post Details

View the full post that these comments belong to

Error Responses

StatusDescription
404Post not found - the specified post ID does not exist
Terminal window
curl -X GET "https://jsonplaceholder.typicode.com/posts/1/comments"
const response = await fetch("https://jsonplaceholder.typicode.com/posts/1/comments");
const data = await response.json();
console.log(data);
import requests
response = requests.get("https://jsonplaceholder.typicode.com/posts/1/comments")
print(response.json())
[
{
"postId": 1,
"id": 1,
"name": "id labore ex et quam laborum",
"email": "[email protected]",
"body": "laudantium enim quasi est quidem magnam voluptate ipsam eos\ntempora quo necessitatibus\ndolor quam autem quasi\nreiciendis et nam sapiente accusantium"
},
{
"postId": 1,
"id": 2,
"name": "quo vero reiciendis velit similique earum",
"email": "[email protected]",
"body": "est natus enim nihil est dolore omnis voluptatem numquam\net omnis occaecati quod ullam at\nvoluptatem error expedita pariatur\nnihil sint nostrum voluptatem reiciendis et"
}
]
{
"error": "Post not found"
}
Request
curl -X GET "https://jsonplaceholder.typicode.com/posts/{id}/comments" \
  -H "Content-Type: application/json"
const response = await fetch("https://jsonplaceholder.typicode.com/posts/{id}/comments", {
  method: "GET",
  headers: {
    "Content-Type": "application/json"
},
});

const data = await response.json();
console.log(data);
import requests

response = requests.get(
    "https://jsonplaceholder.typicode.com/posts/{id}/comments",
    headers={'Content-Type':'application/json'},
)

print(response.json())
package main

import (
    "fmt"
    "net/http"
    "io"
)

func main() {
    req, _ := http.NewRequest("GET", "https://jsonplaceholder.typicode.com/posts/{id}/comments", nil)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
Response
Send a request to see the response