import React, { useState } from 'react'; import { Card, CardContent, CardHeader } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Separator } from '@/components/ui/separator'; import { Badge } from '@/components/ui/badge'; import { Code, Terminal, Book, ChevronRight, Copy, Check, Home, AlertTriangle, Zap } from 'lucide-react'; import { useToast } from '@/hooks/use-toast'; import { Link } from 'react-router-dom'; import { APIPlayground } from '@/components/APIPlayground'; const Docs = () => { const [copiedSection, setCopiedSection] = useState(null); const { toast } = useToast(); const copyToClipboard = (text: string, section: string) => { navigator.clipboard.writeText(text); setCopiedSection(section); setTimeout(() => setCopiedSection(null), 2000); toast({ title: "Copied!", description: "Code copied to clipboard", }); }; const apiUrl = 'https://gjhfnqiknusundbktwxs.supabase.co/functions/v1/analyze-seo'; return (
{/* Header */}
Back to SEO Tester
$ api-documentation

SEO Analyzer API

→ RESTful API for programmatic SEO analysis

{/* Quick Start */}
Quick Start
GET STARTED
ENDPOINT
{apiUrl}
POST METHOD
{/* Request Format */}
Request Format
HEADERS
Content-Type: application/json
REQUEST BODY
{`{
  "url": "https://example.com"
}`}
                
{/* Response Format */}
Response Format
SUCCESS RESPONSE (200)
{`{
  "success": true,
  "data": {
    "title": "Page Title",
    "description": "Meta description",
    "ogTitle": "OG Title",
    "ogDescription": "OG Description",
    "ogImage": "https://example.com/image.jpg",
    "ogType": "website",
    "twitterCard": "summary_large_image",
    "twitterTitle": "Twitter Title",
    "twitterDescription": "Twitter Description",
    "twitterImage": "https://example.com/image.jpg",
    "h1": "Main Heading",
    "canonical": "https://example.com",
    "keywords": "keyword1, keyword2",
    "lang": "en",
    "viewport": "width=device-width, initial-scale=1",
    "charset": "UTF-8",
    "metaRobots": "index,follow",
    "url": "https://example.com"
  },
  "score": {
    "total": 85,
    "breakdown": {
      "basic": 35,
      "social": 30,
      "technical": 20
    }
  }
}`}
              
{/* API Playground */}
Interactive Playground
{/* Batch Analysis */}
Batch Analysis

Analyze multiple URLs in a single request (max 5 URLs):

BATCH REQUEST
{`{
  "urls": [
    "https://example.com",
    "https://another-site.com"
  ]
}`}
                
{/* Response Schema */}
Response Schema
successboolean - Analysis success status
cachedboolean - Whether result was cached
data.titlestring - Page title tag
data.descriptionstring - Meta description
data.ogImagestring - Open Graph image URL
score.totalnumber - Overall SEO score (0-100)
score.breakdownobject - Score breakdown by category
{/* Troubleshooting */}
Troubleshooting

Rate Limiting (429)

Maximum 10 requests per minute per IP. Wait 60 seconds before retrying.

Invalid URL (400)

Ensure URL starts with http:// or https:// and is properly formatted.

Failed to Fetch (502)

Target website may be blocking requests or experiencing issues. Try a different URL.

Caching

Results are cached for 1 hour. Cached responses include "cached": true field.

{/* Code Examples */}
Code Examples
{/* JavaScript/Fetch */}
JAVASCRIPT (FETCH)
{`fetch('${apiUrl}', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://example.com'
  })
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));`}
                
{/* cURL */}
CURL
{`curl -X POST '${apiUrl}' \\
  -H 'Content-Type: application/json' \\
  -d '{"url": "https://example.com"}'`}
                
{/* Python */}
PYTHON
{`import requests

url = "${apiUrl}"
payload = {"url": "https://example.com"}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)
print(response.json())`}
                
{/* Error Responses */}
Error Responses
400 BAD REQUEST
{`{
  "error": "URL parameter is required"
}`}
                
500 INTERNAL ERROR
{`{
  "success": false,
  "error": "Failed to fetch website"
}`}
                
); }; export default Docs;