API Overview

Powerful Social APIs that enable you to send social media posts and get analytics effortlessly. For developers and businesses of all sizes.

Ayrshare's Social Media API

The Social Media REST API allows programmatic access to the functionality of Ayrshare, such as posting and deleting status updates, getting analytics, adding comments, and more to multiple social. Current social networks supported are Facebook Pages, X/Twitter, LinkedIn, Instagram, YouTube, Google My Business (Google Business Profile), Pinterest, Reddit, TikTok, and Telegram.

If you are on the Business or Enterprise Plan and manage multiple users, see the Business Plan Overview and /profiles API endpoint.

Key Functionality

  • Authorized access based on your secret API Key (obtained at ayrshare.com).

  • Publish posts immediately or scheduled future posts on linked social networks.

  • Send posts on a predetermined automated schedule.

  • Post images and videos, including Reels.

  • Delete posts on linked social networks.

  • Analytics on post engagement, likes, shares, and more.

  • Analytics on the social account, such as followers and demographics.

  • Get and add comments to posts.

  • Auto shorten links in posts or shorten specific links.

  • TweetStorms for longer Tweets using Twitter Threads.

  • Add specific Unsplash images or randomly select an Unsplash image based on a search term.

  • Automatically add hashtags to your posts based on the most relevant key words.

  • Get history of posts and their status, even post that didn't go through Ayrshare.

  • Retrieve, reply, and delete replies of reviews.

  • Add or delete an RSS feeds for automated posts.

  • Get and respond to reviews.

  • Upload media (photos and videos) to media gallery to be used in posts.

Business Plan

As a Business Plan member, you can manage multiple user and client profiles from your platform.

  • Allow your users to connect their social media accounts.

  • Post to multiple user profiles with one API call.

  • Create and delete user profiles via the API.

  • Advanced User Analytics and Webhooks.

Learn more about the Business Plan.

Max Pack

Get even more capabilities with the Max Pack add-on:

pageMax Pack

Watch How to Use the Social API

If you're building in Node.js, check out this video on how to connect and post to Twitter and Facebook.

Authorization

Ayrshare authenticates API requests via an Authorization token passed in the HTTP header. Please be sure to send Bearer with the API Key. The API Key can be found in the Ayrshare Dashboard by switching to your Primary Profile.

HTTP Header Format: Authorization: Bearer API_KEY replacing API_KEY with your primary API Key.

curl -H "Authorization: Bearer API_KEY" https://app.ayrshare.com

Obtain your secret API key in the Ayrshare dashboard under API Key.

For example, if your API Key is 2MPXPKQ-S03M5LS-GR5RX5G-AZCK8EA

Your header should include:

Authorization: Bearer 2MPXPKQ-S03M5LS-GR5RX5G-AZCK8EA

Profile Key

You may specify a User Profile by adding the Profile Key, returned when creating a User Profile or found in the Dashboard, in the header.

HTTP Header Format: Profile-Key: PROFILE_KEY replacing PROFILE_KEY with the User's Profile Key.

curl -H "Profile-Key: PROFILE_KEY" https://app.ayrshare.com

Content-Type

Data should always be passed as Content-Type: "application/json"

curl -H "Content-Type: application/json" https://app.ayrshare.com

Compression

Add an Accept-Encoding header to compress the response with Accept-Encoding: "deflate, gzip". This is recommended for calling larger responses like the /history endpoint. Please be sure you can properly uncompress the response.

curl -H "Accept-Encoding: deflate, gzip" https://app.ayrshare.com

Ayrshare Post ID vs Social ID

There are primarily two types of IDs used throughout call:

  • Ayrshare Post ID: This ID is generated by Ayrshare and returned from the /post endpoint in the id field. This ID makes it easy to get analytics on the post across social networks, add comments to the post, delete the post, etc. This is the ID you will use most often.

  • Social ID: Each social network assigns their own unique ID to posts and comments. These IDs are returned in the postIds field of the /post or /comments endpoints. You can use these IDs, or ones you get directly from the social networks, to retrieve data, such as with the analytics social ID.

Error Codes

Errors will return with standard HTTP status codes.

For more information:

pageHTTP Status Codes

Detailed Errors are in the REST API response specific for each type of call.

For more information:

pageAyrshare Error Codes

Timestamp Format

We utilize Zulu Time, also known as UTC (Coordinated Universal Time) or an ISO 8601 formatted date string, for a precise and unambiguous time references across different time zones.

For example: 2024-01-21T00:46:49.238Z

You can convert the UTC format to you local time in the programming language of your choice. For example in JavaScript:

const convertToLocalTime = (isoString) => {
  // Create a new Date object from the ISO string
  const date = new Date(isoString);
  
  // Extract local time components
  const localDate = date.toLocaleDateString();
  const localTime = date.toLocaleTimeString();
  
  // Combine the local date and time
  const localDateTime = `${localDate} ${localTime}`;
  
  return localDateTime;
}

Postman

You can use Postman to test your REST API calls.

pageTest with Postman

Random Posts, Images, and Videos

Check out out quick start guide on how to send random posts, images, or videos when testing.

Packages

We have both Node.js & Python packages and Bubble.io and Airtable guides available to make the RESTful calls easier.

pageAirtablepageBubble.iopageNode.js NPMpagePython PyPI

Last updated