- Core API's
- >
- Comments API Documentation
Comments API Documentation
A Simple to use CRUD API for your Comments application. This API is ready to use with any frontend/backend framework or language.
Endpoints
Name | Endpoint | Method | Copy |
---|---|---|---|
Comment List | /api/comments | GET | |
Comment Detail | /api/comments/1 | GET | |
Comment Create | /api/comments | POST | |
Comment Update | /api/comments/1 | PUT | |
Comment Delete | /api/comments/1 | DELETE |
How to Use
Comment List API
fetch('https://simplecrudapi.com/api/posts/1/comments')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
Comment Detail API
fetch('https://simplecrudapi.com/api/comments/1')
.then(response => response.json())
.then(data => {
console.log('Comment for post 1 with ID 1:', data);
})
.catch(error => console.error(error));
Comment Create API
fetch('https://simplecrudapi.com/api/comments', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'post_id': 1,
'content': 'This is a beautifully crafted comment, expressing a thoughtful and engaging response to the post. It highlights key points and adds valuable insight to the conversation.'
})
})
.then(response => response.json())
.then(json => console.log(json))
.catch(error => console.error('Error posting data:', error));
Comment Update API
fetch('https://simplecrudapi.com/api/comments/1', {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
'content': 'This is a beautifully crafted comment, expressing a thoughtful and engaging response to the post. It highlights key points and adds valuable insight to the conversation.',
'post_id': 1
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error))
Comment Delete API
fetch('https://simplecrudapi.com/api/comments/1', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error))
Code Sandbox Demos
No Code sandbox demos found yet!
No demos found, You can create a demo and contact us to put that with your credit link.
Contact UsOr,
Browse All Code sandbox Demos