FLASH SALE: 50% OFF all content generation packages! View Pricing

InstaPress AI

API Examples

Code examples for integrating InstaPress API in different programming languages

cURL

curl -X POST https://api.instapress.ai/generate-article?user_id=YOUR_USER_ID \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "topic": "The Future of AI",
    "length": "medium",
    "focus": "research"
  }'

Python

import requests

api_key = "YOUR_API_KEY"
user_id = "YOUR_USER_ID"

response = requests.post(
    "https://api.instapress.ai/generate-article",
    params={"user_id": user_id},
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json"
    },
    json={
        "topic": "The Future of AI",
        "length": "medium",
        "focus": "research"
    }
)

if response.status_code == 200:
    content = response.json()["content"]
    print(content)

JavaScript

const generateArticle = async () => {
  const response = await fetch(
    'https://api.instapress.ai/generate-article?user_id=YOUR_USER_ID',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        topic: 'The Future of AI',
        length: 'medium',
        focus: 'research'
      })
    }
  );

  if (response.ok) {
    const { content } = await response.json();
    console.log(content);
  }
};

PHP

<?php
$api_key = 'YOUR_API_KEY';
$user_id = 'YOUR_USER_ID';

$data = array(
    'topic' => 'The Future of AI',
    'length' => 'medium',
    'focus' => 'research'
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.instapress.ai/generate-article?user_id=" . $user_id);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Authorization: Bearer ' . $api_key,
    'Content-Type: application/json'
));

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

$result = json_decode($response, true);
if (isset($result['content'])) {
    echo $result['content'];
}
?>

Important Notes

  • Replace YOUR_API_KEY with your actual API key from the dashboard
  • Replace YOUR_USER_ID with your user ID from the dashboard
  • Always keep your API key secure and never expose it in client-side code
  • Check the Endpoints documentation for all available parameters