# PostNitro Embed SDK

> **Integrate a full-featured AI-powered social media content creator into your platform in minutes**

Transform your platform with PostNitro's proven content creation technology. Instead of spending months building a social media design tool from scratch, embed our battle-tested solution that's already trusted by 44,000+ creators and 70+ platforms worldwide.

## Why PostNitro?

[PostNitro](https://postnitro.ai) is the leading AI-powered content generator that helps users create stunning, professional carousels, single images, and videos for Instagram, LinkedIn, TikTok, and other social platforms. Our technology powers content creation across multiple industries, from marketing agencies to e-commerce platforms.


## Quick Start

### Installation

```bash
npm install @postnitro/embed
```

### Import Options

**Module Import (Recommended for React, Next.js, Vue, etc.)**
```typescript
import { createEditor } from "@postnitro/embed";
```

**Script Tag (Traditional web applications)**
```html
<script src="https://cdn.jsdelivr.net/npm/@postnitro/embed/dist/index.umd.js"></script>
```

## Setup & Configuration

### 1. Obtain Your API Key

Get your free API key to start integrating. Follow our [step-by-step guide](https://postnitro.ai/docs/embed/obtaining-an-api-key) to:
- Access your PostNitro account
- Configure domain whitelisting for security
- Generate your unique API key

### 2. Initialize the Editor

**Module Initialization:**
```typescript
const editor = createEditor({
    apiKey: "your-api-key",
});
```

**Script Initialization:**
```typescript
const editor = window.postnitroEmbed.createEditor({
    apiKey: "your-api-key",
});
```

## Core Functionality

### Create New Content

Enable your users to create professional social media content from scratch:

```typescript
editor?.createDesign((data: ExportData) => {
    console.log("New content created:", data);
    // Save the content data to your database
    // Display success message to user
    // Redirect to content management page
});
```

### Edit Existing Content

Allow users to modify their previously created designs:

```typescript
editor?.editDesign('content-id', (data: ExportData) => {
    console.log("Content updated:", data);
    // Update content in your database
    // Notify user of successful changes
});
```

## Export Data Structure

When users complete their design, your callback function receives rich export data:

```typescript
interface ExportData {
    id: string;           // Unique identifier for the content
    name: string;         // User-defined content name
    size: string;         // Aspect ratio (e.g., "16:9", "1:1", "9:16")
    type: string;         // Export format: "pdf", "png", or "mp4"
    data: Blob | Blob[];  // File data - single Blob for PDF/MP4, Blob array for PNG
}
```

### Export Types Explained

- **PNG**: Image files returned as `Blob[]` (multiple files for carousels, single file for images)
- **PDF**: Single PDF document returned as `Blob` (multi-page for carousels, single page for images)
- **MP4**: Single video file returned as `Blob` (slideshow for carousels, animated content for videos)

## Integration Example

Here's a complete example showing PostNitro Embed in a real application:

```html
<!DOCTYPE html>
<html>
  <head>
    <title>My Platform - Content Creator</title>
  </head>
  <body>
    <div class="content-tools">
      <button id="createContentBtn">Create New Content</button>
      <button id="editContentBtn">Edit Existing Content</button>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/@postnitro/embed/dist/index.umd.js"></script>
    <script>
      // Initialize PostNitro Editor
      const editor = window.postnitroEmbed.createEditor({
        apiKey: "your-api-key",
      });

      // Handle new content creation
      document.getElementById("createContentBtn").addEventListener("click", () => {
        editor.createDesign((data) => {
          console.log("New content created:", data);
          
          // Save to your platform's database
          saveContentToDatabase(data);
          
          // Show success message
          showSuccessMessage(`Content "${data.name}" created successfully!`);
        });
      });

      // Handle content editing
      document.getElementById("editContentBtn").addEventListener("click", () => {
        const contentId = getCurrentContentId(); // Your logic to get ID
        
        editor.editDesign(contentId, (data) => {
          console.log("Content updated:", data);
          
          // Update in your database
          updateContentInDatabase(data);
          
          // Notify user
          showSuccessMessage(`Content "${data.name}" updated successfully!`);
        });
      });
    </script>
  </body>
</html>
```

## Next Steps

Ready to transform your platform with professional social media content creation capabilities?

1. **[Get Your API Key](https://postnitro.ai/docs/embed/obtaining-an-api-key)** - Free to start, takes less than 2 minutes
2. **[View Full Documentation](https://postnitro.ai/docs/embed)** - Complete integration guide and advanced features
3. **[Explore PostNitro](https://postnitro.ai)** - See the full platform your users will access

## Support & Resources

- **[Complete Documentation](https://postnitro.ai/docs/embed)**
- **[API Reference](https://postnitro.ai/docs/embed)**
- **Support**: [support@postnitro.ai](mailto:support@postnitro.ai)

---

**Ready to enhance your platform?** Join the 70+ platforms already using PostNitro Embed to deliver professional social media content creation to their users. [Get started today →](https://postnitro.ai)
