Copyright API Documentation
Overview
The Copyright API provides a simple way to generate copyright text with the correct year range and entity name. It's useful for automatically updating copyright notices in footers and legal pages.
Loading copyright...
API Reference
Endpoint
bash
GET /api/copyright
Query Parameters
Parameter | Type | Default | Description |
---|---|---|---|
startYear | number | Current year | The starting year for the copyright range |
entity | string | "Your Company" | The name of the company or entity |
Response
json
{
"text": "© 2022–2025 Example Corp. All rights reserved.",
"year": 2025,
"startYear": 2022,
"entity": "Example Corp"
}
Usage Examples
Direct API Call
javascript
// Fetch with default parameters
fetch('/api/copyright')
.then(response => response.json())
.then(data => console.log(data.text));
// Fetch with custom parameters
fetch('/api/copyright?startYear=2020&entity=Acme%20Inc')
.then(response => response.json())
.then(data => console.log(data.text));
Using the CopyrightFooter Component
jsx
// Default usage
<CopyrightFooter />
// With custom parameters
<CopyrightFooter startYear={2020} entity="Acme Inc" />
Server-Side Usage
jsx
// In a Server Component
async function getCopyrightText() {
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/copyright?startYear=2020&entity=Acme%20Inc`);
const data = await response.json();
return data.text;
}
export default async function Page() {
const copyrightText = await getCopyrightText();
return (
<footer>
<p>{copyrightText}</p>
</footer>
);
}