clusterify.ai

Generate FAQ API Documentation

Why Use This API?

This API enables blog and e-commerce site owners to generate frequently asked questions (FAQs) based on provided content. Well-crafted FAQs enhance user experience by addressing common queries, reducing support requests, and improving SEO through rich, keyword-optimized content. This service streamlines the creation of informative and relevant FAQs, saving time and effort while boosting your website's authority and search engine visibility.

Technical Details

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

Request Parameters

ParameterTypeRequiredDescription
promptstringYesThe text content based on which FAQs will be generated (minimum 100 characters, maximum 5000 characters).
lengthnumberNoOptional. The number of FAQs to generate (integer between 1 and 10). Default is 5.

Response

The API returns a JSON object containing the generated FAQs, each with a question and its corresponding answer. The FAQs are tailored to be relevant, clear, and concise based on the provided context.

{
  "faqs": [
    {
      "question": "First frequently asked question?",
      "answer": "Answer to the first question."
    },
    {
      "question": "Second frequently asked question?",
      "answer": "Answer to the second question."
    }
    // ... up to length FAQs
  ]
}

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-faq \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your_token" \
  -d '{
    "prompt": "Your lengthy text content goes here...",
    "length": 5
}'

Example API Call Using Python

import requests

url = "https://clusterify.ai/api/generate-faq"
headers = {
    "Authorization": "Bearer your_token",
    "Content-Type": "application/json"
}
data = {
    "prompt": "Your lengthy text content goes here...",
    "length": 5
}

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

Example API Call Using Next.js (Fetch)

async function generateFAQs() {
  const res = await fetch('https://clusterify.ai/api/generate-faq', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer your_token',
    },
    body: JSON.stringify({
      prompt: 'Your lengthy text content goes here...',
      length: 5
    }),
  });

  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-faq");
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([
    "prompt" => "Your lengthy text content goes here...",
    "length" => 5
]);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

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

echo $response;
?>

© 2024, Clusterify.ai All Rights Reserved.