clusterify.ai

Generate Blog Post API Documentation

Why Use This API?

This API generates SEO-optimized blog posts tailored to specific subjects and keywords. A well-written blog post can enhance your website's SEO performance, engage readers, and establish your brand's authority. This service streamlines content creation, saving you time and effort while improving your online visibility.

Technical Details

The API is located at https://clusterify.ai/api/generate-blogpost and accepts a POST request.

Request Parameters

ParameterTypeRequiredDescription
subjectstringYesThe main topic for the blog post.
keywordstringNoOptional field for SEO optimization (10-80 characters).
promptstringNoOptional custom prompt for content generation (5-80 characters).
lengthstringYesThe desired length of the blog post (short, medium, long).

Response

The API returns a JSON object containing the generated blog post, including the title, meta keywords, meta description, and structured content. The response structure is as follows:

{
  "title": "example title",
  "meta": {
    "keywords": "keyword1 keyword2 ...",
    "description": "meta description"
  },
  "initial": "short initial paragraph",
  "content": [
    {
      "subtitle": "this is a sub-title",
      "paragraph": "paragraph content"
    },
    {
      "subtitle": "this is a sub-title",
      "paragraph": "paragraph content"
    },
    {
      "subtitle": "this is a sub-title",
      "paragraph": "paragraph content"
    }
  ],
  "url-key": "generated url key, seo optimized"
}

Authentication

You need a JWT token to authenticate. Use the login API to get your token. Here’s an example with CURL:

curl -X POST https://clusterify.ai/api/login \
  -H "Content-Type: application/json" \
  -d '{"public_key": "your_public_key", "secret_key": "your_secret_key"}'

This call returns a JWT token to use for authentication in the API request.

Example API Call Using CURL

curl -X POST https://clusterify.ai/api/generate-blogpost \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your_token" \
  -d '{
    "subject": "The Importance of Eco-Friendly Products",
    "keyword": "eco-friendly products",
    "prompt": "write a comprehensive article",
    "length": "medium"
}'

Example API Call Using Python

import requests

url = "https://clusterify.ai/api/generate-blogpost"
headers = {
    "Authorization": "Bearer your_token",
    "Content-Type": "application/json"
}
data = {
    "subject": "The Importance of Eco-Friendly Products",
    "keyword": "eco-friendly products",
    "prompt": "write a comprehensive article",
    "length": "medium"
}

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

Example API Call Using Next.js (Fetch)

async function generateBlogPost() {
  const res = await fetch('https://clusterify.ai/api/generate-blogpost', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer your_token',
    },
    body: JSON.stringify({
      subject: 'The Importance of Eco-Friendly Products',
      keyword: 'eco-friendly products',
      prompt: 'write a comprehensive article',
      length: 'medium'
    }),
  });

  const data = await res.json();
  console.log(data);
}

Example API Call Using PHP

<?php
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://clusterify.ai/api/generate-blogpost");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Authorization: Bearer your_token",
    "Content-Type: application/json"
));
$data = json_encode([
    "subject" => "The Importance of Eco-Friendly Products",
    "keyword" => "eco-friendly products",
    "prompt" => "write a comprehensive article",
    "length" => "medium"
]);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

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

echo $response;
?>

© 2024, Clusterify.ai All Rights Reserved.