The REST API
Need to fetch your comments programmatically? The JamComments REST API lets you access your comments via HTTP request. All API requests go to https://go.jamcomments.com.
Retrieving Comments
Section titled “Retrieving Comments”Fetch a paginated list of comments for a specific page or your entire site. Only approved comments are returned.
Endpoint
Section titled “Endpoint”GET /api/comments
Authentication
Section titled “Authentication”Include your API token in the Authorization header:
Authorization: Bearer 12345-YOUR-API-TOKENYou can create or view your API token in the JamComments admin.
Query Parameters
Section titled “Query Parameters”| Parameter | Required? | Description |
|---|---|---|
domain | Yes | Your site’s domain (as configured in your account). |
path | No | The page path for the comments you want. Leave blank to get all comments for the domain. |
per_page | No | How many top-level comments to return per page. Default is 50. |
Example Request
Section titled “Example Request”fetch( "https://go.jamcomments.com/api/comments?domain=example.com&path=/posts/my-post", { headers: { Authorization: "Bearer YOUR_API_TOKEN_HERE", }, },) .then((response) => response.json()) .then((data) => console.log(data));Response Format
Section titled “Response Format”The API returns a JSON object with your comments and pagination info:
{ "data": [ { "created_at": "2023-11-26T06:30:07.000000Z", "content": "This is some example content.", "html": "<p>This is some example content.</p>\n", "status": "approved", "name": "Jane Doe", "path": "/posts/my-blog-post", "children": [ { "created_at": "2023-11-26T06:30:07.000000Z", "content": "Totally agree!", "html": "<p>Totally agree!</p>\n", "status": "approved", "name": "John Smith", "path": "/posts/my-blog-post" } ] } ], "links": { "first": "https://go.jamcomments.com/api/comments?page=1", "last": "https://go.jamcomments.com/api/comments?page=1", "prev": null, "next": null }, "meta": { "current_page": 1, "from": 1, "last_page": 1, "per_page": 50, "to": 16, "total": 16 }}Note: The children array contains reply comments nested under their parent comment.
Have Feedback?
Section titled “Have Feedback?”If you have suggestions for the API or need additional endpoints, send me an email!