analytics
Get real-time analytical data for posts, such as clicks, likes, shares, and impressions.
Click the β€Ί in the endpoint to view details.

Request Examples

cURL
Node.js
Python
PHP
C#
1
curl \
2
-H "Authorization: Bearer API_Key" \
3
-H 'Content-Type: application/json' \
4
-X GET https://app.ayrshare.com/api/analytics/links?lastDays=2
Copied!
1
const fetch = require("node-fetch");
2
const API_KEY = "API_KEY";
3
const lastDays = 2;
4
​
5
fetch(`https://app.ayrshare.com/api/analytics/links?lastDays=${lastDays}`, {
6
method: "GET",
7
headers: {
8
"Content-Type": "application/json",
9
"Authorization": `Bearer ${API_KEY}`
10
}
11
})
12
.then((res) => res.json())
13
.then((json) => console.log(json))
14
.catch(console.error);
Copied!
1
import requests
2
​
3
headers = {'Content-Type': 'application/json',
4
'Authorization': 'Bearer API_KEY'}
5
​
6
r = requests.delete('https://app.ayrshare.com/api/analytics/links?lastDays=2',
7
headers=headers)
8
9
print(r.json())
Copied!
1
<?php
2
require 'vendor/autoload.php'; // Composer auto-loader
3
​
4
$lastdays = "2";
5
$client = new GuzzleHttp\Client();
6
$res = $client->request(
7
'GET',
8
'https://app.ayrshare.com/api/analytics/links?lastDays=' . $lastdays,
9
[
10
'headers' => [
11
'Content-Type' => 'application/json',
12
'Authorization' => 'Bearer API_KEY'
13
]
14
]
15
);
16
​
17
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
Copied!
1
using System;
2
using System.Net;
3
using System.IO;
4
​
5
namespace LinksGETRequest_charp
6
{
7
class Links
8
{
9
static void Main(string[] args)
10
{
11
string API_KEY = "API_KEY";
12
string url = "https://app.ayrshare.com/api/analytics/links";
13
​
14
var httpWebRequest = WebRequest.CreateHttp(url);
15
httpWebRequest.ContentType = "application/json";
16
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
17
​
18
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
19
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
20
{
21
var response = streamReader.ReadToEnd();
22
Console.WriteLine(response);
23
}
24
}
25
}
26
}
Copied!
​
post
https://app.ayrshare.com/api
/analytics/post
Analytics on a Post

Request Examples

cURL
Node.js
Python
PHP
Go
C#
1
curl \
2
-H "Authorization: Bearer API_KEY" \
3
-H 'Content-Type: application/json' \
4
-d '{"id": "Post ID", "platforms": ["facebook", "instagram", "twitter", "youtube", "linkedin"]}' \
5
-X POST https://app.ayrshare.com/api/analytics/post
Copied!
1
const fetch = require("node-fetch");
2
const API_KEY = "API_KEY";
3
​
4
fetch("https://app.ayrshare.com/api/analytics/post", {
5
method: "POST",
6
headers: {
7
"Content-Type": "application/json",
8
"Authorization": `Bearer ${API_KEY}`
9
},
10
body: JSON.stringify({
11
id: "Post ID", // required
12
platforms: ["facebook", "instagram", "twitter", "youtube", "linkedin"], // required
13
}),
14
})
15
.then((res) => res.json())
16
.then((json) => console.log(json))
17
.catch(console.error);
Copied!
1
import requests
2
​
3
payload = {'id': 'Post ID',
4
'platforms': ['facebook', 'instagram', 'twitter', 'youtube', 'linkedin']}
5
headers = {'Content-Type': 'application/json',
6
'Authorization': 'Bearer API_KEY'}
7
​
8
r = requests.post('https://app.ayrshare.com/api/analytics/post',
9
json=payload,
10
headers=headers)
11
12
print(r.json())
Copied!
1
<?php
2
require 'vendor/autoload.php'; // Composer auto-loader
3
​
4
$client = new GuzzleHttp\Client();
5
$res = $client->request(
6
'POST',
7
'https://app.ayrshare.com/api/post',
8
[
9
'headers' => [
10
'Content-Type' => 'application/json',
11
'Authorization' => 'Bearer API_KEY'
12
],
13
'json' => [
14
'id' => 'Post ID',
15
'platforms' => ['facebook', 'instagram', 'twitter', 'youtube', 'linkedin'], // required
16
]
17
]
18
);
19
​
20
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
Copied!
1
package main
2
​
3
import (
4
"bytes"
5
"encoding/json"
6
"log"
7
"net/http"
8
)
9
​
10
func main() {
11
message := map[string]interface{}{
12
"id": "Post ID",
13
"platforms": []string{"facebook", "instagram", "twitter", "youtube", "linkedin"},
14
}
15
​
16
bytesRepresentation, err := json.Marshal(message)
17
if err != nil {
18
log.Fatalln(err)
19
}
20
​
21
req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/post",
22
bytes.NewBuffer(bytesRepresentation))
23
​
24
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
25
req.Header.Add("Authorization", "Bearer API_KEY")
26
​
27
res, err := http.DefaultClient.Do(req)
28
if err != nil {
29
log.Fatal("Error:", err)
30
}
31
​
32
res.Body.Close()
33
}
Copied!
1
using System;
2
using System.Net;
3
using System.IO;
4
​
5
namespace PostAnalyticsPOSTRequest_charp
6
{
7
class PostAnalytics
8
{
9
static void Main(string[] args)
10
{
11
string API_KEY = "API_KEY";
12
string url = "https://app.ayrshare.com/api/analytics/post";
13
​
14
var httpWebRequest = WebRequest.CreateHttp(url);
15
httpWebRequest.ContentType = "application/json";
16
httpWebRequest.Method = "POST";
17
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
18
​
19
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
20
{
21
string json = "{\"id\" : \"Post ID\","
22
+ "\"platforms\" : [ \"facebook\", \"instagram\", \"twitter\", \"youtube\", \"linkedin\" ]";
23
​
24
streamWriter.Write(json);
25
streamWriter.Flush();
26
}
27
​
28
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
29
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
30
{
31
var response = streamReader.ReadToEnd();
32
Console.WriteLine(response);
33
}
34
}
35
}
36
}
Copied!
​
post
https://app.ayrshare.com/api
/analytics/social
Analytics on a Social Network
cURL
Node.js
Python
PHP
Go
C#
1
curl \
2
-H "Authorization: Bearer API_KEY" \
3
-H 'Content-Type: application/json' \
4
-d '{"platforms": ["facebook", "instagram", "twitter"]}' \
5
-X POST https://app.ayrshare.com/api/analytics/social
Copied!
1
const fetch = require("node-fetch");
2
const API_KEY = "API_KEY";
3
​
4
fetch("https://app.ayrshare.com/api/analytics/social", {
5
method: "POST",
6
headers: {
7
"Content-Type": "application/json",
8
"Authorization": `Bearer ${API_KEY}`
9
},
10
body: JSON.stringify({
11
platforms: ["facebook", "instagram", "twitter"], // required
12
}),
13
})
14
.then((res) => res.json())
15
.then((json) => console.log(json))
16
.catch(console.error);
Copied!
1
import requests
2
​
3
payload = {'platforms': ['facebook', 'instagram', 'twitter']}
4
headers = {'Content-Type': 'application/json',
5
'Authorization': 'Bearer API_KEY'}
6
​
7
r = requests.post('https://app.ayrshare.com/api/analytics/social',
8
json=payload,
9
headers=headers)
10
11
print(r.json())
Copied!
1
<?php
2
require 'vendor/autoload.php'; // Composer auto-loader
3
​
4
$client = new GuzzleHttp\Client();
5
$res = $client->request(
6
'POST',
7
'https://app.ayrshare.com/api/social',
8
[
9
'headers' => [
10
'Content-Type' => 'application/json',
11
'Authorization' => 'Bearer API_KEY'
12
],
13
'json' => [
14
'platforms' => ['facebook', 'instagram', 'twitter'], // required
15
]
16
]
17
);
18
​
19
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
Copied!
1
package main
2
​
3
import (
4
"bytes"
5
"encoding/json"
6
"log"
7
"net/http"
8
)
9
​
10
func main() {
11
message := map[string]interface{}{
12
"platforms": []string{"facebook", "instagram", "twitter"},
13
}
14
​
15
bytesRepresentation, err := json.Marshal(message)
16
if err != nil {
17
log.Fatalln(err)
18
}
19
​
20
req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/social",
21
bytes.NewBuffer(bytesRepresentation))
22
​
23
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
24
req.Header.Add("Authorization", "Bearer API_KEY")
25
​
26
res, err := http.DefaultClient.Do(req)
27
if err != nil {
28
log.Fatal("Error:", err)
29
}
30
​
31
res.Body.Close()
32
}
Copied!
1
using System;
2
using System.Net;
3
using System.IO;
4
​
5
namespace PostAnalyticsPOSTRequest_charp
6
{
7
class PostAnalytics
8
{
9
static void Main(string[] args)
10
{
11
string API_KEY = "API_KEY";
12
string url = "https://app.ayrshare.com/api/analytics/social";
13
​
14
var httpWebRequest = WebRequest.CreateHttp(url);
15
httpWebRequest.ContentType = "application/json";
16
httpWebRequest.Method = "POST";
17
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
18
​
19
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
20
{
21
string json = "\"platforms\" : [ \"facebook\", \"instagram\", \"twitter\" ]";
22
​
23
streamWriter.Write(json);
24
streamWriter.Flush();
25
}
26
​
27
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
28
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
29
{
30
var response = streamReader.ReadToEnd();
31
Console.WriteLine(response);
32
}
33
}
34
}
35
}
Copied!

Analytics for Profiles

Get post analytics for a particular user profile by passing the profileKey parameter as a String in the body.
Business or Enterprise Plan required.
1
const fetch = require("node-fetch");
2
const API_KEY = "API_KEY";
3
const PROFILE_KEY = "PROFILE_KEY";
4
​
5
fetch("https://app.ayrshare.com/api/analytics/post", {
6
method: "POST",
7
headers: {
8
"Content-Type": "application/json",
9
"Authorization": `Bearer ${API_KEY}`
10
},
11
body: JSON.stringify({
12
id: "Post ID", // required
13
platforms: ["facebook", "instagram", "twitter", "youtube", "linkedin"], // required
14
profileKey: PROFILE_KEY // Profile key as a String
15
}),
16
})
17
.then((res) => res.json())
18
.then((json) => console.log(json))
19
.catch(console.error);
Copied!
Last modified 12d ago