'use client' import { useState } from 'react' import Link from 'next/link' export default function Playground() { const [apiKey, setApiKey] = useState('') const [url, setUrl] = useState('https://example.com') const [endpoint, setEndpoint] = useState('screenshot') const [options, setOptions] = useState('{}') const [result, setResult] = useState('') const [loading, setLoading] = useState(false) const [codeLang, setCodeLang] = useState('curl') const endpoints = [ { value: 'screenshot', label: 'Screenshot' }, { value: 'pdf', label: 'PDF' }, { value: 'crawl', label: 'Crawl' }, { value: 'content', label: 'Content' }, { value: 'markdown', label: 'Markdown' }, { value: 'json', label: 'JSON' }, { value: 'links', label: 'Links' }, { value: 'scrape', label: 'Scrape' }, { value: 'snapshot', label: 'Snapshot' }, { value: 'extract', label: 'AI Extract' }, ] async function sendRequest() { setLoading(true) try { const body: any = { url } if (options && options !== '{}') { body.options = JSON.parse(options) } const res = await fetch(`http://localhost:3000/api/${endpoint}`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey, }, body: JSON.stringify(body), }) const data = await res.json() setResult(JSON.stringify(data, null, 2)) } catch (e) { setResult(String(e)) } finally { setLoading(false) } } function getCodeSnippet() { const body = JSON.stringify({ url, options: JSON.parse(options || '{}') }, null, 2) switch (codeLang) { case 'curl': return `curl -X POST http://localhost:3000/api/${endpoint} \\ -H "Content-Type: application/json" \\ -H "x-api-key: ${apiKey || 'YOUR_API_KEY'}" \\ -d '${body}'` case 'python': return `import requests response = requests.post( "http://localhost:3000/api/${endpoint}", headers={ "Content-Type": "application/json", "x-api-key": "${apiKey || 'YOUR_API_KEY'}" }, json=${body.replace(/true/g, 'True').replace(/false/g, 'False').replace(/null/g, 'None')} ) print(response.json())` case 'javascript': return `const response = await fetch('http://localhost:3000/api/${endpoint}', { method: 'POST', headers: { 'Content-Type': 'application/json', 'x-api-key': '${apiKey || 'YOUR_API_KEY'}' }, body: JSON.stringify(${body}) }); const data = await response.json(); console.log(data);` default: return '' } } return (

API Playground

Test any endpoint directly from the browser.

Request

setApiKey(e.target.value)} placeholder="your-api-key" style={{ width: '100%', padding: 10, background: '#1a1a1a', border: '1px solid #333', borderRadius: 6, color: '#fff', fontSize: 13, boxSizing: 'border-box' }} />
setUrl(e.target.value)} style={{ width: '100%', padding: 10, background: '#1a1a1a', border: '1px solid #333', borderRadius: 6, color: '#fff', fontSize: 13, boxSizing: 'border-box' }} />