Ayrshare Docs
Ask or search…
K
Comment on page

comments

Comments API Endpoint: Post and manage comments on a post.

Comments API Endpoint

Click the in the endpoint to view details.
post
https://app.ayrshare.com/api
/comments
Post a Comment

Request Examples

cURL
Node.js
Python
PHP
Go
C#
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"id": "Ut1fWU6XkqkMayHGnJZ", "platforms": ["facebook", "instagram", "linkedin", "reddit", "tiktok", "twitter", "youtube"], "comment": "An amazing comment!"}' \
-X POST https://app.ayrshare.com/api/comments
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/comments", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
id: "Ut1fWU6XkqkMayHGnJZ", // required
platforms: ["facebook", "instagram", "linkedin", "reddit", "tiktok", "twitter", "youtube"], // required
comment: "An amazing comment!", //required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'id': 'Ut1fWU6XkqkMayHGnJZ',
'platforms': ['facebook', 'instagram', 'linkedin', 'reddit', 'tiktok', 'twitter', 'youtube'],
'comment': 'An amaxing comment!'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/comments',
json=payload,
headers=headers)
print(r.json())
<?php
$apiUrl = 'https://app.ayrshare.com/api/comments';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$data = json_encode([
'id' => 'Ut1fWU6XkqkMayHGnJZ', // Replace with your actual post ID
'platforms' => ['facebook', 'instagram', 'linkedin', 'reddit', 'tiktok', 'twitter', 'youtube'],
'comment' => 'An amazing comment!'
]);
$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $data
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
curl_close($curl);
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"id": "Ut1fWU6XkqkMayHGnJZ", // required
"platforms": []string{"facebook", "instagram", "linkedin", "reddit", "tiktok", "twitter", "youtube"}, // required
"comment": []string{"An amazing comment!"} // required
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/comments",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
using System;
using System.Net;
using System.IO;
namespace PostPOSTRequest_charp
{
class Post
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/comments";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"id\" : \"Ut1fWU6XkqkMayHGnJZ\","
+ "\"platforms\" : [ \"facebook\", \"instagram\", \"linkedin\", \"reddit\", \"tiktok\", \"twitter\", \"youtube\"],"
+ "\"comment\" : [ \"An amazing comment!\" ]}";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}
get
https://app.ayrshare.com/api
/comments/:id
Get Comments

Request Examples

cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ', headers=headers)
print(r.json())
<?php
$apiUrl = 'https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ'; // Replace with your post ID
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
curl_close($curl);
using System;
using System.Net;
using System.IO;
namespace UserGETRequest_charp
{
class User
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}
delete
https://app.ayrshare.com/api
/comments/:id
Delete Comments

Request Examples

cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API_KEY" \
-X DELETE https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ", {
method: "DELETE",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.delete('https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ', headers=headers)
print(r.json())
<?php
$apiUrl = 'https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ'; // Replace with your post ID
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$curl = curl_init($apiUrl);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => $headers
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'Curl error: ' . curl_error($curl);
} else {
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
curl_close($curl);
using System;
using System.Net;
using System.IO;
namespace UserGETRequest_charp
{
class User
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
var httpResponse = (HttpWebResponse)httpWebRequest.DeleteResponse();
using (var streamReader = new StreamReader(httpResponse.DeleteResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

User Profile Comments

Get comments or post comments for a particular user profile by adding the PROFILE_KEY in the header.

Comments by Social ID

Available for Business Plan users only.

Get Comments

Retrieve comments for posts that did not originate via Ayrshare by providing the Social Post ID. This ID is returned in the postIds field of the /post endpoint.
Get Comments with Social ID
Use the Get All Post History endpoint to retrieve posts and IDs originating outside of Ayrshare found in the Social Post ID field.
The linked account must the owner of the post to retrieve the comments.
Support platforms: Facebook, Instagram, LinkedIn, TikTok, Twitter, and YouTube with the following platform values: facebook, instagram, linkedin, tiktok, twitter, youtube
For example, the Get All Post History responses with the Facebook Social ID 104619420979033_758005082307127. This is the Facebook assigned post ID. You can use this ID to retrieve all the comments on this post.
GET https://app.ayrshare.com/api/comments/104619420979033_758005082307127?searchPlatformId=true&platform=facebook
Get a Comment with Social Comment ID
For Facebook and Instagram only you can retrieve a single comment and replies by using the Social Comment ID instead of the Social ID and the additional query parameter commentId=true. For example, the GET /comments endpoint returns the Facebook Social Comment ID 158472752285927_358472912285911. You can then make a call to get the comment and replies with the ID and the commentId=true query parameter:
GET https://app.ayrshare.com/api/comments/104619420979033_758005082307127?commentId=true&searchPlatformId=true&platform=facebook

Post a Comment

Publish a comment to a post that was not sent via Ayrshare by using the low-level post Social ID. This ID is returned in the postIds field of the /post endpoint.
Use the Get All Post History endpoint to retrieve posts and IDs originating outside of Ayrshare found in the id field.
The linked account must the owner of the post to retrieve the comments. Support platforms: Facebook, Instagram, LinkedIn, TikTok, and Twitter.
POST https://app.ayrshare.com/api/comments
{
"id": "17945530655454295", // Required: Low-level post id return from /post or get all history
"platforms": ["instagram"], // Required: Only one social network allowed
"comment": "This is my new comment, // Required.
"searchPlatformId": true // Required.
}

Delete a Comment

Delete a comment that was not sent via Ayrshare by using the low-level Social ID commentId returned for a particular social network. Supported platforms: Facebook, TikTok, and Twitter.
DELETE https://app.ayrshare.com/api/comments/1yNwQOwYmNhqqQRZwvxZ?searchPlatformId=true&platform=facebook
Last modified 11h ago