Ayrshare Docs
Ask or search…
K
Comment on page

analytics

Analytics API Endpoint: Get real-time analytical data for posts and social accounts, such as clicks, likes, shares, followers, and impressions.

Analytic API Endpoint

Click the in the endpoint to view details.

Request Examples

cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API_Key" \
-H 'Content-Type: application/json' \
-X GET https://app.ayrshare.com/api/analytics/links?lastDays=2
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
const lastDays = 2;
fetch(`https://app.ayrshare.com/api/analytics/links?lastDays=${lastDays}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.delete('https://app.ayrshare.com/api/analytics/links?lastDays=2',
headers=headers)
print(r.json())
<?php
$lastdays = "2";
$apiUrl = 'https://app.ayrshare.com/api/analytics/links?lastDays=' . $lastdays;
$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 LinksGETRequest_charp
{
class Links
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/analytics/links";
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);
}
}
}
}
post
https://app.ayrshare.com/api
/analytics/post
Analytics on a Post
Get real-time analytics such as likes, impressions, retweets, etc for a given post that originated via Ayrshare. Will only return the analytics of networks where the post was sent.
For analytics on posts originating outside of Ayrshare see Analytics by Social ID.
Notes
Only Facebook Pages, Instagram, Twitter, LinkedIn, Pinterest, TikTok, and YouTube are currently supported.
You might need to unlink and re-link Facebook and Instagram in the Dashboard's Social Accounts Page to grant the new Analytics permissions.
Twitter Threads returns as an Array of objects, with each object corresponding to a Tweet in the Thread.
YouTube can take up to 24 hours to process analytics for videos with fewer views.
TikTok account owners need to first publish at least one video, then tap the "Turn On" button on the Analytics page of their mobile TikTok app. You will receive more insights about your viewers and the content they've engaged with once you have 100 followers.
LinkedIn limits the analytics on posts to personal pages. Please see in the 200 response for more details. Premium or Business Plan required.
Parameters
Header
Authentication*
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body
id*
string
Ayrshare Post ID returned from the /post endpoint. This is the top level Ayrshare id returned and not the social ids in postIds.
platforms
array
String array of platforms to retrieve analytics. For example: ["instagram", "facebook", "linkedin",
"pinterest", "reddit",
"tiktok",
"twitter", "youtube"].
If platforms is not included, all the analytics on all of the social networks the post was sent will be returned.
Responses
200: OK
Successful return of analytics
404: Not Found
Error getting post analytics at social networks
404: Not Found
Top level post ID not found

Request Examples

cURL
Node.js
Python
PHP
Go
C#
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"id": "Post ID", "platforms": ["facebook", "instagram", "twitter", "youtube", "tiktok", "linkedin", "pinterest"]}' \
-X POST https://app.ayrshare.com/api/analytics/post
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/analytics/post", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
id: "Post ID", // required
platforms: ["facebook", "instagram", "twitter", "youtube", "tiktok", "linkedin", "pinterest"], // optional
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'id': 'Post ID',
'platforms': ['facebook', 'instagram', 'twitter', 'youtube', 'tiktok', 'linkedin', 'pinterest']}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/analytics/post',
json=payload,
headers=headers)
print(r.json())
<?php
$apiUrl = 'https://app.ayrshare.com/api/analytics/post';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$data = json_encode([
'id' => 'Post ID', // Replace with your actual Post ID
'platforms' => ['facebook', 'instagram', 'twitter', 'youtube', 'tiktok', 'linkedin', 'pinterest'] // optional
]);
$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": "Post ID",
"platforms": []string{"facebook", "instagram", "twitter", "youtube", "tiktok, "linkedin", "pinterest"},
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/analytics/post",
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 PostAnalyticsPOSTRequest_charp
{
class PostAnalytics
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/analytics/analytics/post";
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\" : \"Post ID\","
+ "\"platforms\" : [ \"facebook\", \"instagram\", \"twitter\", \"youtube\", \"tiktok\", \"linkedin\", \"pinterest\" ]";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}
post
https://app.ayrshare.com/api
/analytics/social
Analytics on a Social Network
Get analytics and demographics on a user's social profile, such as impressions, views, and followers.
Currently available for Facebook Pages, Instagram Accounts, Twitter handles, LinkedIn Company Pages, YouTube Channels, Google My Business accounts, TikTok accounts, Reddit, and Pinterest Users.
Facebook Page analytics is generally only available on Pages with 100 or more likes, such as demographics. Facebook typically updates their metrics once every 24 hours.
LinkedIn only supports Company Page analytics. LinkedIn count totals are eventually consistent, but not immediately consistent, and can take up to 24-48 hours in some cases.
Parameters
Header
Authorization*
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body
platforms*
array
Social media platforms to get analytics. Accepts an array of Strings with values: facebook, gmb, instagram, linkedin, pinterest, reddit, tiktok, twitter, youtube.
Responses
200
Successful response for social analytics
400: Bad Request
Error response if missing or wrong platform
400: Bad Request
Social network not linked

Request Examples

cURL
Node.js
Python
PHP
Go
C#
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"platforms": ["facebook", "instagram", "twitter", "linkedin", "pinterest", "youtube", "tiktok"]}' \
-X POST https://app.ayrshare.com/api/analytics/social
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/analytics/social", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
platforms: ["facebook", "instagram", "twitter", "linkedin", "pinterest", "tiktok", "youtube"], // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'platforms': ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok']}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/analytics/social',
json=payload,
headers=headers)
print(r.json())
<?php
$apiUrl = 'https://app.ayrshare.com/api/analytics/social';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
$headers = [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey,
];
$data = json_encode([
'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'] // required
]);
$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{}{
"platforms": []string{"facebook", "instagram", "twitter", "linkedin", "pinterest", "youtube", "tiktok"},
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/social",
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 PostAnalyticsPOSTRequest_charp
{
class PostAnalytics
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/analytics/social";
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 = "\"platforms\" : [ \"facebook\", \"instagram\", \"twitter\", \"linkedin\", \"pinterest\", \"youtube\", \"tiktok\" ]";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

User Profile Analytics

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

Analytics Overview Video

Social Media API Analytics Overview
post
https://app.ayrshare.com
/api/analytics/post
Analytics by Social ID
Retrieve analytics for posts that did not originate via Ayrshare by providing the low-level 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 analytics. Support platforms: Facebook, Instagram, LinkedIn, TikTok, Twitter, and YouTube.
Recommend to only use for posts not sent via Ayrshare.
Available for Business Plan users only.
Parameters
Header
Authorization*
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Body
id*
string
Social ID from /post endpoint contained in postIds
platforms*
array
Only one value accepted: facebook, instagram, linkedin, tiktok, twitter, youtube
searchPlatformId*
boolean
Always equals true
Responses
200: OK
Successful return of analytics
404: Not Found
Post ID not found
Available for Business Plan users only.

Request JSON Example

{
"id": "104923907983682_108329000309742", // Facebook Social ID
"platforms": [
"facebook" // Select only one platform at a time: facebook, instagram, youtube, or twitter
],
"searchPlatformId": true
}
Please see the /post endpoint Response 200 for an example of the Facebook ID 104923907983682_108329000309742
get
https://app.ayrshare.com
/api/analytics/youTubePlaylists
YouTube Playlists
Get the YouTube playlists for the connected YouTube channel.
Parameters
Header
Authorization*
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Responses
200: OK
Successful return of playlists
400: Bad Request
Error getting analytics

Request Examples

cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://app.ayrshare.com/api/analytics/youTubePlaylists
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/analytics/youTubePlaylists", {
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/analytics/youTubePlaylists', headers=headers)
print(r.json())
<?php
$apiUrl = 'https://app.ayrshare.com/api/analytics/youTubePlaylists';
$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 HistoryGETRequest_charp
{
class History
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/analytics/youTubePlaylists";
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);
}
}
}
}
get
https://app.ayrshare.com/api
/getInstagramOnlineFollowers
Count of Instagram followers online

Request Examples

cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://app.ayrshare.com/api/analytics/getInstagramOnlineFollowers?date=2023-12-03
const API_KEY = "API_KEY";
const date = "2023-12-03";
fetch(`https://app.ayrshare.com/api/analytics/getInstagramOnlineFollowers?date=${date}`, {
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/analytics/getInstagramOnlineFollowers?date=2023-12-03', headers=headers)
print(r.json())
<?php
// URL and authorization details
$url = 'https://app.ayrshare.com/api/analytics/getInstagramOnlineFollowers?date=2023-12-03';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
// Initialize a cURL session
$curl = curl_init();
// Set cURL options
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Execute cURL session and get the response
$response = curl_exec($curl);
// Check if any error occurred
if(curl_errno($curl)){
echo 'Curl error: ' . curl_error($curl);
} else {
// Decode and re-encode the JSON response to pretty print
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
// Close cURL session
curl_close($curl);
using System;
using System.Net;
using System.IO;
namespace HistoryGETRequest_charp
{
class History
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/analytics/getInstagramOnlineFollowers?date=2023-12-03";
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);
}
}
}
}
Last modified 2h ago