Nominating Presidential Muppets
Miss any of our Open RFC calls?Watch the recordings here! »


1.0.6 • Public • Published

Automated Social Media Posting APIs

Social Post API is a client for Ayrshare's APIs. Ayrshare is a powerful set of APIs that enable you to automate server-side social media posts to Twitter, Facebook, LinkedIn, Reddit, and Telegram. The Ayrshare API handles all the setup and maintenance for the social media networks. One API to rule them all (yeah, went there). See the full list of features.

Ayrshare also provides data integrations such as RSS and Substack to automate the creation of content.

Also, check out our video of installing and using the package.


npm i social-post-api


  1. Create a free Ayrshare account.

    alt Social Accounts Setup

  2. Enable your social media accounts such as Twitter, Facebook, LinkedIn, Reddit, or Telegram in the Ayrshare dashboard.

    alt Social Accounts Setup

  3. Copy your API Key from the Ayrshare dashboard. Used for authentication.

    alt API Key

Getting Started

Initialize Social Post API

Create a new Social Post object with your API Key.

const SocialPost = require("social-post-api");
const social = new SocialPost(API_KEY);

History, Post, Delete Example

This simple example shows how to post, get history, and delete the post. This example assumes you have a free API key from Ayrshare and have enabled Twitter, Facebook, and LinkedIn. Note, Telegram and Reddit also available.

const SocialPost = require("social-post-api");
const API_KEY = "8jKj782Aw8910dCN"; // get an API Key at
const social = new SocialPost(API_KEY);
const run = async () => {
  /** post */
  const post = await{
    post: "One more time",
    platforms: ["twitter", "facebook", "linkedin"],
  /** history */
  const history = await social.history()
  /** delete */
  const deletePost = await social.delete({ id: })



Published a new post to the specified social networks either immediately or at scheduled future date. Returns a promise that resolves to an object containing the post ID and post status (success, error).

const postResponse = await{
    // Required
    post: "Best post ever!",
    // Required: Social media platforms to post. 
    // Accepts an array of strings with values: "facebook", "twitter", "linkedin", "reddit", or "telegram".
    platforms: ["twitter", "facebook", "linkedin", "telegram", "reddit"],
    // Optional: URLs of images to include in the post
    media_urls: [""],
    // Optional: Datetime to schedule a future post. 
    // Accepts an ISO-8601 UTC date time in format "YYYY-MM-DDThh:mm:ssZ". Example: 2021-07-08T12:30:00Z
    scheduleDate: "2020-08-07T15:17:00Z",
    // Required if platform includes "reddit." Title of Reddit post.
    title: "My Reddit Post",
    // Required if platform includes "reddit." Subreddit to post.
    subreddit: "test",
    // Optional: Shorten links in the post for all platforms similar to
    // Only URLS starting with http or https will be shortened. Default value: true.
    shorten_links: true


Delete a post with a given post ID, obtained from the "post" response. Returns a promise with the delete status. Also, can bulk delete multiple IDs at once using the "bulk" key.

const deleteResponse = await social.delete({
    // Required
    id: "POST ID",                          // optional, but required if "bulk" not present
    bulk: ["Post ID 1", "Post ID 2", ...]   // optional, but required if "id" not present


Get a history of all posts and their current status in descending order. Returns a promise that resolves to an array of post objects.

const historyResponse = await social.history({
  lastRecords: 10,    // optional: returns the last X number of history records
  lastDays: 30,       // optional: returns the last X number of days of history records. Defaults to 30 if not present.

Upload Media

Upload and store a new image. Returns a URL referencing the image. Can be used in "image_url" in "post".

const uploadResponse = await social.upload({
    // Required: The image as a Base64 encoded string. Example encoding:
    // Optional
    fileName: "test.png",
    // Optional
    description: "best image"

Get Media

Get all media URLS. Returns a promise that resolves to an array of URL objects.

const mediaResponse = await;


Get data about the logged in user, such as post quota, used quota, active social networks, and created date.

const user = await social.user().catch(console.error);

Shorten URL

Shorten a URL and return the shortened URL.

const shortenResponse = await social.shorten({
    // Required: URL to shorten
    url: "",


Get analytics on shortened links: clicked and source of clicks for iOS, Android, or Desktop.

const analytics = await{
  // Optional range 1-7, default 1 day.
  lastDays: 3

Add an RSS or Substack Feed

Add a new RSS or Substack feed to auto post all new articles. Returns a promise that resolved to an object containing the feed ID. See How to Automate Your Blog or Newsletter for more info.

const feedResponse = await social.feedAdd({
    // Required: URL to shorten
    url: "https://theRSSFeed",
    // Optional: Value: "rss" or "substack". 
    // If not set, defaults to "rss"
    type: "RSS",

Delete an RSS or Substack Feed

Delete an RSS feed for a given ID.

const feedResponse = await social.feedDelete({
    // Required: ID of the feed
    id: "Feed ID",

Additional Information

Additional examples, responses, etc can be found at:

API REST Endpoint Docs


npm i social-post-api

DownloadsWeekly Downloads






Unpacked Size

11.5 kB

Total Files


Last publish


  • avatar