The Social Media REST API provides developers with programmatic access to multiple social networks through a single unified interface. Through this API, you can manage social media activities including creating and deleting posts, retrieving analytics, engaging with comments, and performing other social media actions across platforms. The API currently supports ten major social networks: Facebook Pages, X (formerly Twitter), LinkedIn, Instagram, YouTube, Google Business Profile, Pinterest, Reddit, TikTok, and Telegram. By integrating with this API, developers can automate social media management tasks across all these platforms simultaneously.

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

Key Functionality

  • Secure API access using your unique API Key.
  • Instant or scheduled posting to connected social media platforms.
  • Automated posting based on predefined schedules.
  • Support for image and video content, including Reels and Stories.
  • Delete posts on linked social networks.
  • Comprehensive post engagement analytics (likes, shares, etc.).
  • Social account metrics, including follower count and demographic data.
  • Comment management: view, add, and delete post comments.
  • Optional link shortening for all or specific URLs in posts.
  • Unsplash integration: add specific images or randomly select based on keywords.
  • Automatic hashtag generation option using relevant keywords.
  • Post history tracking, including non-Ayrshare posts.
  • Review management: retrieve, reply to, and delete review responses.
  • RSS feed integration for automated content posting.
  • Media library: upload and store photos and videos for use in posts.

Business Plan

Business Plan features for managing multiple users and clients:

  • Enable users to link their own social media accounts to your platform.
  • Secure single sign-on using OAuth for quick account linking.
  • Create and remove user profiles programmatically through the API.
  • Access advanced user analytics and receive real-time updates via webhooks.

Contact us to learn more about the Business Plan.

Messages

A unified messaging API to engage users in conversations across the major social media channels: Facebook, Instagram, and X.

  • Sending text, image, and video messages.
  • Retrieving complete conversation histories.
  • Setting up automated message responses.
  • Receiving real-time updates via webhooks for messages received, message reactions, read receipts.

This API simplifies user engagement by centralizing messaging operations for multiple social media channels. Learn more…

Messages

Explore the unified messaging API.

Max Pack

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

Max Pack

Unlock advanced features like AI-powered content generation, enhanced analytics, and expanded platform support with our Max Pack add-on.

Watch How to Use the Social API

If you’re building in Node.js, check out this video on how to connect and publish posts to X and Facebook.

Social API Demo

If you use Node.js see the social API demo code to get started building your own social API integration.

Social API Demo

Explore our Node.js demo code to jumpstart your social API integration

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.

If you are a Business or Enterprise user, you can create User Profiles with Profile Keys to manage multiple clients. The Profile Key is used in the header of your requests. The API Key must also be used in the header of your requests for User Profiles.

API Key Format

Authorization: Bearer API_KEY replacing API_KEY with your Primary Profile API Key, which can be found in the Ayrshare Dashboard.

Obtain your secret API Key in the Ayrshare dashboard under the API Key page found in the left navigation panel.

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

Your header should include:

Authorization: Bearer 2MPXPKQ-S03M5LS-GR5RX5G-AZCK8EA

Profile Key Format

Profile-Key: PROFILE_KEY replacing PROFILE_KEY with a user’s Profile Key.

Including a Profile Key in the header is required to interact on behalf of a User Profile.

A missing Primary Profile API Key or using the Profile Key in place of the API Key in the header will result in an error.

Here’s how to structure the headers for API requests:

Find the Profile Key in the Ayrshare Dashboard under the Profile Key page found in the left navigation panel. Switch to the Profile you want to use in teh User Profile page.

For example, if your Profile Key is AX1XGG-9jK3M5LS-GR5RX5G-LLCK8EA

Your header should include both the API and Profile Key:

Authorization: Bearer 2MPXPKQ-S03M5LS-GR5RX5G-AZCK8EA

Profile-Key: AX1XGG-9jK3M5LS-GR5RX5G-LLCK8EA

Content Type

The Content Type should always be set as Content-Type: "application/json" unless the endpoint specifically specifies otherwise.

Compression

Ayrshare supports gzip compression for all API requests. To enable compression, set the Accept-Encoding header to deflate, gzip. Accept-Encoding: "deflate, gzip" This is recommended for calling larger responses such as the /history endpoint.

Don’t forget to properly uncompress the response.

ID Types

There are primarily two types of IDs used returned, which can be used in various endpoints:

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 Post 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 post ID.

Ayrshare Comment ID

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

This is often used if you want to get details on a particular comment published via Ayrshare.

Social Comment ID

Each social network assigns their own unique ID to comments. These IDs are returned in the commentId field of the GET /comments endpoint.

This is often used if you want to get details on a particular comment published outside of Ayrshare.

Error Codes

Errors will return with standard HTTP status codes.

For more information:

HTTP Status Codes

Learn more about HTTP status codes

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

For more information:

Ayrshare Error Codes

Learn more about Ayrshare-specific error codes

Timestamp Format

Ayrshare uses 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.

Postman

Learn how to use Postman with our API

Random Posts, Images, and Videos

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

Packages

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