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
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$lastdays = "2";
$client = new GuzzleHttp\Client();
$res = $client->request(
'GET',
'https://app.ayrshare.com/api/analytics/links?lastDays=' . $lastdays,
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
]
]
);
​
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
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

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 fetch = require("node-fetch");
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"], // required
}),
})
.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
require 'vendor/autoload.php';// Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/post',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'id' => 'Post ID',
'platforms' => ['facebook', 'instagram', 'twitter', 'youtube', 'tiktok', 'linkedin', 'pinterest'], // required
]
]
);
​
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
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/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/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
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
require 'vendor/autoload.php';// Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
​
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/social',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'], // required
]
]
);
​
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
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 passing the profileKey parameter as a String in the body.
Business or Enterprise Plan required.
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
const PROFILE_KEY = "PROFILE_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", "linkedin"], // required
profileKey: PROFILE_KEY // Profile key as a String
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);

Analytics Overview Video

Social Media API Analytics Overview
​
post
https://app.ayrshare.com
/api/analytics/post
Analytics by Social ID
Available for Business Plan users only.

Request JSON Example

{
"id": "1120578291857109", // ID from Facebook
"platforms": [
"facebook" // Select only one platform at a time: facebook, instagram, youtube, or twitter
],
"searchPlatformId": true
}
Copy link
On this page
Analytic API Endpoint
get
Analytics on a Shortened Link
Request Examples
post
Analytics on a Post
Request Examples
post
Analytics on a Social Network
User Profile Analytics
Analytics Overview Video
post
Analytics by Social ID
Request JSON Example