Nexpost Logo
Sign In Try Nexpost
  1. Home
  2. API Documentation
Developer Resources πŸš€

NexPost API Documentation

Complete REST API documentation for generating social media content using artificial intelligence. Build powerful integrations with our content generation endpoints for LinkedIn, Twitter, Instagram, and Facebook.

Quick Start Authentication API Reference Code Examples System Status Troubleshooting

Getting Started

Welcome to the NexPost API! Our REST API allows you to programmatically generate engaging social media content using advanced AI technology. Get started in just a few minutes.

1 Get Your API Key

Sign up for a NexPost account and generate your API key from the Settings page.

Generate API Key β†’

2 Make Your First Request

Use our interactive API explorer below to test endpoints and see responses.

Try API Explorer β†’

Quick Start Example

curl -X POST https://nexpost.io/api/content/generate-post \\
  -H "Content-Type: application/json" \\
  -H "x-api-key: YOUR_API_KEY" \\
  -d '{
    "contentType": "linkedin",
    "topic": "AI in marketing",
    "description": "Write about benefits of AI automation"
  }'

Base URL

https://nexpost.io/api

All API requests should be made to this base URL with the appropriate endpoint path.

API Authorization

To use the API, you need an API key. You can find it in the Settings section.

Include the key in the header of each request: x-api-key: YOUR_API_KEY

πŸ’‘ Testing Tip: Click the "Authorize" button in the API documentation below to add your API key and test endpoints directly!

Interactive API Documentation

Below you'll find interactive documentation for all available API endpoints. You can test the endpoints directly from this interface.

Code Examples

Generate LinkedIn Post

curl -X POST https://nexpost.io/api/content/generate-post \\
  -H "Content-Type: application/json" \\
  -H "x-api-key: YOUR_API_KEY" \\
  -d '{
    "contentType": "linkedin",
    "topic": "Remote work productivity",
    "description": "Share tips for effective work from home",
    "streaming": false
  }'

Generate Post from Image

curl -X POST https://nexpost.io/api/content/generate-custom-post \\
  -H "Content-Type: application/json" \\
  -H "x-api-key: YOUR_API_KEY" \\
  -d '{
    "contentType": "instagram",
    "imageBase64": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==",
    "imageMimeType": "image/png",
    "imageDescription": "Simple test image",
    "streaming": false
  }'

Generate Content Topics

curl -X POST https://nexpost.io/api/content/generate-topics \\
  -H "Content-Type: application/json" \\
  -H "x-api-key: YOUR_API_KEY" \\
  -d '{
    "limit": 10,
    "description": "remote work productivity tips"
  }'

Generate Content with Fetch API

const response = await fetch('https://nexpost.io/api/content/generate-post', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
    contentType: 'twitter',
    topic: 'AI technology trends',
    description: 'Discuss latest developments in AI',
    streaming: false
  })
});

const data = await response.json();
console.log(data.content);

Streaming Response Example

const response = await fetch('https://nexpost.io/api/content/generate-post', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
    contentType: 'linkedin',
    topic: 'Digital marketing',
    streaming: true
  })
});

const reader = response.body.getReader();
const decoder = new TextDecoder();

while (true) {
  const { value, done } = await reader.read();
  if (done) break;
  
  const chunk = decoder.decode(value);
  const lines = chunk.split('\\n');
  
  for (const line of lines) {
    if (line.startsWith('data: ')) {
      const data = JSON.parse(line.slice(6));
      console.log(data.content);
      if (data.isComplete) break;
    }
  }
}

Generate Topic Ideas

const response = await fetch('https://nexpost.io/api/content/generate-topics', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
    limit: 15,
    description: 'artificial intelligence and machine learning'
  })
});

const topics = await response.json();
console.log('Generated topics:', topics);

// Example output:
// [
//   "The AI breakthrough that changed everything in 2024",
//   "Why ChatGPT is just the beginning of the AI revolution",
//   "5 machine learning concepts every professional should know"
// ]

Basic Request with Requests Library

import requests
import json

url = "https://nexpost.io/api/content/generate-post"
headers = {
    "Content-Type": "application/json",
    "x-api-key": "YOUR_API_KEY"
}

data = {
    "contentType": "facebook",
    "topic": "Sustainable living",
    "description": "Share eco-friendly tips for daily life",
    "streaming": False
}

response = requests.post(url, headers=headers, json=data)
result = response.json()

print(result["content"])

Image-based Content Generation

import requests

# Simple example with minimal base64 image (1x1 pixel)
simple_image = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="

url = "https://nexpost.io/api/content/generate-custom-post"
headers = {
    "Content-Type": "application/json",
    "x-api-key": "YOUR_API_KEY"
}

data = {
    "contentType": "instagram",
    "imageBase64": simple_image,
    "imageMimeType": "image/png",
    "imageDescription": "Simple test image for API testing"
}

response = requests.post(url, headers=headers, json=data)
result = response.json()

print(result["content"])

# Or with your own image file:
# import base64
# with open("your_image.jpg", "rb") as image_file:
#     image_data = base64.b64encode(image_file.read()).decode()
#     full_image = f"data:image/jpeg;base64,{image_data}"

Generate Content with cURL

<?php
$url = "https://nexpost.io/api/content/generate-post";
$data = array(
    "contentType" => "linkedin",
    "topic" => "Business growth strategies",
    "description" => "Share insights on scaling startups",
    "streaming" => false
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Content-Type: application/json",
    "x-api-key: YOUR_API_KEY"
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
echo $result["content"];
?>

Using Axios Library

const axios = require('axios');

async function generateContent() {
  try {
    const response = await axios.post('https://nexpost.io/api/content/generate-post', {
      contentType: 'twitter',
      topic: 'Machine learning basics',
      description: 'Explain ML concepts for beginners',
      streaming: false
    }, {
      headers: {
        'Content-Type': 'application/json',
        'x-api-key': 'YOUR_API_KEY'
      }
    });

    console.log(response.data.content);
  } catch (error) {
    console.error('Error:', error.response?.data || error.message);
  }
}

generateContent();

Example Response

{
  "success": true,
  "content": "πŸš€ Remote work isn't just a trendβ€”it's the future of productivity!\\n\\nHere are my top 5 tips for staying productive while working from home:\\n\\nβœ… Create a dedicated workspace\\nβœ… Set clear boundaries with family/roommates\\nβœ… Use time-blocking for focused work sessions\\nβœ… Take regular breaks to avoid burnout\\nβœ… Invest in good lighting and ergonomic setup\\n\\nWhat's your #1 remote work productivity hack? Share below! πŸ‘‡\\n\\n#RemoteWork #Productivity #WorkFromHome #DigitalNomad",
  "contentType": "linkedin",
  "topic": "Remote work productivity"
}

System Status

Monitor the health and availability of NexPost API services in real-time. Check individual service components and overall system status.

Live Status

Overall Status:Checking...
Response Time:-
Uptime:-
Last Check:-

Service Components

Database:
Checking...
AI Service:
Checking...

Status Endpoint

GET https://nexpost.io/api/status

Example Response

{
  "status": "healthy",
  "message": "NexPost API is operational",
  "timestamp": "2025-01-29T10:30:00.000Z",
  "version": "1.0.0",
  "uptime": 86400,
  "responseTime": 45,
  "services": {
    "database": "connected",
    "ai_service": "operational"
  }
}

Troubleshooting

Common Error Responses

401

Unauthorized - Invalid API Key

Your API key is missing, invalid, or has been revoked.

{"statusCode": 401, "statusMessage": "API key is required"}

Solution: Check your API key in the Settings page and ensure it's included in the x-api-key header.

429

Rate Limited

You've exceeded your rate limit for API requests.

{"statusCode": 429, "statusMessage": "Rate limit exceeded"}

Solution: Wait before making another request. Each account has 100 requests per month limit.

400

Bad Request - Missing Parameters

Required parameters are missing from your request.

{"statusCode": 400, "statusMessage": "Content type and topic are required"}

Solution: Ensure all required fields (contentType, topic) are included in your request body.

500

Internal Server Error

Something went wrong on our end while processing your request.

{"statusCode": 500, "statusMessage": "Failed to generate content"}

Solution: Try again in a few moments. If the issue persists, contact support.

Debug Checklist

API key is correctly formatted and included in x-api-key header
Request URL is correct (https://nexpost.io/api/...)
Content-Type header is set to application/json
Request body contains required fields (contentType, topic)
JSON payload is properly formatted
Network connection is stable

Need More Help?

If you're still experiencing issues after checking the troubleshooting guide, we're here to help you get back on track.

Email Support

Frequently Asked Questions

How do I get an API key?

You can generate your API key by going to the Settings page in your NexPost dashboard. Click on "Generate Key" to create a new API key.

What social media platforms are supported?

Our API supports content generation for LinkedIn, Twitter, Instagram, and Facebook. Each platform has optimized content formats and character limits.

Is there rate limiting on the API?

Yes, API calls are rate limited. Each account has a limit of 100 requests per month.

Nexpost Logo
Privacy Policy API Documentation Contact
Β© 2025 Nexpost. All rights reserved.
Powered by Railway