> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js NPM

> Integrate the Ayrshare API into your Node app with the Social API NPM Package

## Overview

Ayrshare's [Social API NPM Package](https://www.npmjs.com/package/social-media-api) 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.

```bash theme={"system"}
npm i social-media-api
```

<Info>Obtain your secret API Key in the [Ayrshare Dashboard](https://app.ayrshare.com/).</Info>

### General Usage

Examples of Post, History, and Delete:

<Info>
  **Posting to X/Twitter?** Starting March 31, 2026, X requires your own API credentials. Add 4 BYO headers to your request. See the [setup guide](/dashboard/connect-social-accounts/x-twitter-byo-keys) for details.
</Info>

```javascript theme={"system"}
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

<div class="video-container">
  <iframe width="560" height="315" src="https://www.youtube.com/embed/OMtj2h6sW6U" title="Social Media API NPM Package" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen />
</div>

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:

<Card title="Social API Demo Code" icon="github" href="https://github.com/ayrshare/social-api-demo" horizontal>
  The Social API Demo is a web application that allows users to compose, schedule, and post content
  to multiple social media platforms simultaneously.
</Card>

### More Information and Documentation

<ul class="custom-bullets">
  <li>[NPM Package](https://www.npmjs.com/package/social-media-api)</li>
  <li>[Github Repository](https://github.com/ayrshare/social-media-api)</li>
  <li>[Issue Discussion](https://github.com/ayrshare/social-media-api/issues)</li>
</ul>
