history

get
List History of Posts

https://app.ayrshare.com/api/history
Get a history of all your posts, in descending order (most recent to oldest).
Request
Response
Request
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY. See Overview for more information.
Query Parameters
lastDays
optional
number
Returns the last X days of posts. Default is 30 days. If the value is zero "0", will return the entire history of posts. E.g. lastDays=5 returns the last 5 days of posts and lastDays=0 returns all posts ever sent through Ayrshare.
lastRecords
optional
number
Returns the last X posts. For example, if you only want the most recent post, set lastRecords=1. If not present will return all records contained within lastDays (see above).
Response
200: OK
Successful return of historical posts including success, errors, and deletes. The "id" key is the reference to the post and can be used in the /delete endpoint.
[
{
"errors": [],
"post": "This is the post I sent",
"platforms": [
"twitter",
"facebook"
],
"postIds": [
{
"status": "success",
"id": "1288968500063775749",
"platform": "twitter"
},
{
"id": "104923907983682_108683297607743",
"status": "success",
"platform": "facebook"
}
],
"urls": [],
"type": "now",
"create_date": {
"_seconds": 1596149036,
"_nanoseconds": 358000000
},
"status": "deleted",
"scheduleDate": {
"_seconds": 1596149036,
"_nanoseconds": 0
},
"id": "rhn6u7wwz2WxGv6MZGK9"
},
{
"status": "success",
"platforms": [
"twitter",
"facebook"
],
"create_date": {
"_seconds": 1596130305,
"_nanoseconds": 434000000
},
"post": "Sometimes we need to take a break for lunch.",
"scheduleDate": {
"_seconds": 1596130305,
"_nanoseconds": 0
},
"type": "now",
"postIds": [
{
"platform": "twitter",
"id": "1288890036000983105",
"status": "success"
},
{
"id": "104923907983682_108329970009742",
"status": "success",
"platform": "facebook"
}
],
"errors": [],
"urls": [],
"id": "wWIY0OEirdNeYSJYm1Xa"
},
]

Request Examples

cURL
Node.js
Python
PHP
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://app.ayrshare.com/api/history
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/history", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://app.ayrshare.com/api/history', headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client();
$res = $client->request(
'GET',
'https://app.ayrshare.com/api/history',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
C#
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/history";
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);
}
}
}
}

Profiles

Get history data for a particular user profile by passing the profileKeys parameter as a path parameter.

https://app.ayrshare.com/api/history?profileKeys=ldfnk0s82j

Available for Business Plan users only.