Article comments
Summary of article comments endpoints
- GET /admin/api/articles/1/comments - list all available comments for requested article.
- POST /admin/api/articles/1/comments - create a new comment.
- GET /admin/api/articles/1/comments/1 - get data for a single comment.
- DELETE /admin/api/articles/1/comments/1 - remove a comment.
- PUT /admin/api/articles/1/comments/1/toggle_spam - toggle spam flag of a comment.
- DELETE /admin/api/articles/1/comments/delete_spam - remove all spam comment for requested article.
Related endpoints:
List all available comments for requested article
GET /admin/api/articles/1/comments
By default, this requests returns a list of all comments (spam and non spam) for the requested article (newer first).
This endpoint also allows anonymous access that return only a list of non spam comments.
Example response (authenticated request):
Status: 200 OK
[
{
"id": 2,
"author": "I'm a Spammer!",
"body": "Buy something!",
"spam": false,
"created_at": "2014-02-07T10:54:08.000Z",
"updated_at": "2014-02-07T10:56:07.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1/comments/2",
"article": {
"id": 1,
"title": "How I wrote my first article",
"created_at": "2014-02-07T10:56:07.000Z",
"updated_at": "2014-02-07T10:56:07.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1",
"public_url": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
}
}, {
"id": 1,
"author": "Me",
"body": "Hi!\r\n\r\nThis is a comment!!",
"spam": false,
"created_at": "2014-02-06T15:53:01.000Z",
"updated_at": "2014-02-06T15:53:01.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1/comments/1",
"article": {
"id": 1,
"title": "How I wrote my first article",
"created_at": "2014-02-07T10:56:07.000Z",
"updated_at": "2014-02-07T10:56:07.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1",
"public_url": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
}
}
]
Example response (anonymous request):
Status: 200 OK
[
{
"author": "I'm a Spammer!",
"body": "Buy something!",
"created_at": "2014-02-07T10:54:08.000Z",
"article": {
"id": 1,
"title": "How I wrote my first article",
"created_at": "2014-02-07T10:56:07.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1",
"public_url": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
}
}, {
"author": "Me",
"body": "Hi!\r\n\r\nThis is a comment!!",
"created_at": "2014-02-06T15:53:01.000Z",
"article": {
"id": 1,
"title": "How I wrote my first article",
"created_at": "2014-02-07T10:56:07.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1",
"public_url": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
}
}
]
Parameters
per_page
- elements per response (default:50
; maximum:250
).page
- requested page (default:1
).not_spam
- if present then returns only non spam comments. (eg?not_spam=1
). NB! Applies only to authenticated request.spam
- if present then returns only spam comments. (eg?spam=1
). NB! Applies only to authenticated request.
Filter attributes
Read more about filters.
- Object
comment
attributes:id
,spam
,author
,author_email
,body
,user_agent
,referrer
,created_at
,updated_at
.
Create a new comment
POST /admin/api/articles/1/comments
Allow to post a new comment.
This endpoint also allows anonymous access.
Example data:
{
"author": "Me",
"author_email": "marilyn@monroe.com",
"body": "Hi!\r\n\r\nThis is a comment!!",
"g-recaptcha-response": "valid-response-token"
}
The g-recaptcha-response
value must be include to request when reCAPTCHA is enabled for the article. Read more about [Google reCAPTCHA v3]https://developers.google.com/recaptcha/docs/v3).
Example response (authenticated request):
Status: 201 Created
{
"id": 1,
"author": "Me",
"body": "Hi!\r\n\r\nThis is a comment!!",
"spam": false,
"created_at": "2014-02-06T15:53:01.000Z",
"updated_at": "2014-02-06T15:53:01.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1/comments/1",
"article": {
"id": 1,
"title": "How I wrote my first article",
"created_at": "2014-02-07T10:56:07.000Z",
"updated_at": "2014-02-07T10:56:07.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1",
"public_url": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
},
"author_email": "marilyn@monroe.com",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:27.0) Gecko/20100101 Firefox/27.0",
"referrer": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
}
Example response (anonymous request):
Status: 201 Created
{
"author": "Me",
"body": "Hi!\r\n\r\nThis is a comment!!",
"created_at": "2014-02-06T15:53:01.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1/comments/1",
"article": {
"id": 1,
"title": "How I wrote my first article",
"created_at": "2014-02-07T10:56:07.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1",
"public_url": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
}
}
Parameters
Required parameters are:
author
- comment author name.author_email
- comment author email.body
- comment body.
Get data for a single comment
GET /admin/api/articles/1/comments/1
Example request:
GET http://helloworld.voog.co/admin/api/articles/1/comments/2
Example response:
Status: 200 OK
{
"id": 2,
"author": "I'm a Spammer!",
"body": "Buy something!",
"spam": false,
"created_at": "2014-02-07T10:54:08.000Z",
"updated_at": "2014-02-07T10:54:08.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1/comments/2",
"article": {
"id": 1,
"title": "How I wrote my first article",
"created_at": "2014-02-07T10:56:07.000Z",
"updated_at": "2014-02-07T10:56:07.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1",
"public_url": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
},
"author_email": "spam@spam.com",
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:27.0) Gecko/20100101 Firefox/27.0",
"referrer": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
}
Toggle spam flag of a comment
PUT /admin/api/articles/1/comments/1/toggle_spam
This request toggles the comment spam flag.
Example request:
PUT http://helloworld.voog.co/admin/api/articles/1/comments/2/toggle_spam
Example response:
Status: 200 OK
{
"id": 2,
"author": "I'm a Spammer!",
"body": "Buy something!",
"spam": true,
"created_at": "2014-02-07T10:54:08.000Z",
"updated_at": "2014-02-07T10:54:08.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1/comments/2",
"article": {
"id": 1,
"title": "How I wrote my first article",
"created_at": "2014-02-07T10:56:07.000Z",
"updated_at": "2014-02-07T10:56:07.000Z",
"url": "http://helloworld.voog.co/admin/api/articles/1",
"public_url": "http://helloworld.voog.co/blog/how-i-wrote-my-first-article"
}
}
Remove a comment
DELETE /admin/api/articles/1/comments/1
This request deletes the comment from the database.
Example request:
DELETE http://helloworld.voog.co/admin/api/articles/1/comments/1
Example response:
Status: 204 No Content
Remove all spam comment for requested article
DELETE /admin/api/articles/1/comments/delete_spam
This request deletes all comments flagged as spam under given article.
Example request:
DELETE http://helloworld.voog.co/admin/api/articles/1/comments/delete_spam
Example response:
Status: 200 OK
{
"deleted_count": 1
}