Overview

Ayrshare’s Social API NPM Package allows you to integrate the Ayrshare API into your Node.js app.

Installation

Install the Social API NPM Package if you use Node on the server-side. The package simplifies the calls by wrapping the RESTful calls.

Obtain your secret API Key in the Ayrshare Dashboard.
npm i social-media-api

General Usage

Examples of Post, History, and Delete:

const SocialPost = require("social-media-api");
const API_KEY = "API KEY"; // get an API Key at ayrshare.com
const social = new SocialPost(API_KEY);

const run = async () => {
  /** post */
  const post = await social
    .post({
      post: "One more time",
      platforms: ["twitter", "facebook", "linkedin"],
      profileKey: "DJKJDK-SKDJKDJF" // used with a User Profile
    })
    .catch(console.error);
  console.log(post);

  /** history */
  const history = await social.history().catch(console.error);
  console.log(history);

  /** delete */
  const deletePost = await social.delete({ id: post.id }).catch(console.error);
  console.log(deletePost);
};

run();

Video Overview of the Social Media API NPM Package

Post to Social Media via an API

Profile Key

You may specify the Profile Key for User Profile in the body of a POST or query of a GET with the profileKey field.

Social API Demo

For a sample Node.js integration (using the RESTful API calls), see the GitHub repository:

Social API Demo Code

The Social API Demo is a web application that allows users to compose, schedule, and post content to multiple social media platforms simultaneously.

More Information and Documentation