open-prompt / src /app /api /v1 /route.ts
GitHub Action
Automated sync to Hugging Face
bcce530
import { NextResponse } from 'next/server'
const BASE_URL = process.env.NEXT_PUBLIC_APP_URL || 'https://open-prompt.netlify.app'
/**
* GET /api/v1
* API overview — returns available endpoints, rate limits, and usage info.
*/
export async function GET() {
return NextResponse.json({
name: 'OpenPrompt Public API',
version: '1.0.0',
baseUrl: `${BASE_URL}/api/v1`,
documentation: `${BASE_URL}/docs/api`,
rateLimits: {
guest: '10 requests / hour per IP',
authenticated: '50 requests / hour per user',
pro: '500 requests / hour per user',
},
endpoints: [
{
method: 'GET',
path: '/api/v1/prompts',
description: 'List public prompts',
params: ['q', 'category', 'tags', 'sort', 'page', 'limit'],
},
{
method: 'GET',
path: '/api/v1/prompts/:slug',
description: 'Get a single prompt by slug',
},
{
method: 'POST',
path: '/api/v1/prompts/:slug/run',
description: 'Execute a prompt with variables',
body: { variables: 'object', model: 'string (optional)', stream: 'boolean (optional)' },
},
{
method: 'GET',
path: '/api/v1/tools',
description: 'List all AI tools',
params: ['category', 'q', 'limit'],
},
],
authentication: {
note: 'Authentication not required for public endpoints. Rate limits apply per IP.',
future: 'API key authentication coming soon — sign up at ' + BASE_URL,
},
}, {
headers: {
'Cache-Control': 'public, s-maxage=3600',
},
})
}