Documentation

Quick Start

Get started with Photo Restoration API in just a few minutes. This guide will walk you through the essential steps to integrate AI-powered photo restoration into your application.

Prerequisites

Before you begin, make sure you have:

  • Account: Register at restoreoldphotos.online
  • API Key: Create an API key in settings
  • Credits: Purchase photo restoration credits
  • Image URL: A publicly accessible image URL for testing

Step 1: Get Your API Key

  1. Visit restoreoldphotos.online
  2. Sign in with your Google account
  3. Navigate to Settings > API Keys
  4. Click "Create New API Key" button
  5. Enter a key name (e.g., "My App")
  6. After creating the key, copy the full key value (keep it secure!)

API Key Format

  • Starts with sk-
  • Contains randomly generated characters
  • Example: sk-abc123def456ghi789...

Step 2: Make Your First API Call

Using cURL

curl -X POST https://restoreoldphotos.online/api/api-call/photo-restore \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "imageUrl": "https://example.com/old-photo.jpg"
  }'

Using JavaScript

async function restorePhoto(imageUrl, apiKey) {
  try {
    const response = await fetch('https://restoreoldphotos.online/api/api-call/photo-restore', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'Authorization': `Bearer ${apiKey}`
      },
      body: JSON.stringify({
        imageUrl: imageUrl
      })
    });
 
    if (!response.ok) {
      throw new Error(`API Error: ${response.status}`);
    }
 
    const result = await response.json();
    return result.output; // URL or base64 string
  } catch (error) {
    console.error('Error:', error);
    throw error;
  }
}
 
// Usage
const restoredImage = await restorePhoto(
  'https://example.com/old-photo.jpg',
  'your-api-key-here'
);
console.log('Restored image:', restoredImage);

Step 3: Handle the Response

The API returns a JSON response with the restored image:

{
  "output": "https://replicate.delivery/pbxt/xxx.png"
}

Or in base64 format:

{
  "output": "data:image/png;base64,iVBORw0KGgoAAAANS..."
}

The output field contains:

  • Image URL: Direct link to the restored image
  • Base64 string: Image data encoded as base64

Step 4: Display the Result

In HTML

<img src="https://replicate.delivery/pbxt/xxx.png" alt="Restored Photo" />

In JavaScript

// For URL or base64
const img = document.createElement('img');
img.src = restoredImage; // output field from API response
document.body.appendChild(img);

Step 5: Error Handling

Always implement proper error handling:

try {
  const restoredImage = await restorePhoto(imageUrl, apiKey);
  // Handle success
} catch (error) {
  if (error.message.includes('401')) {
    console.error('Invalid API key');
  } else if (error.message.includes('402')) {
    console.error('Insufficient credits');
  } else if (error.message.includes('429')) {
    console.error('Rate limit exceeded');
  } else {
    console.error('API error:', error.message);
  }
}

API Key Management

Managing Keys in Settings

  • View all API keys list
  • View key usage statistics
  • Deactivate or delete unused keys
  • View last used time for keys

Security Best Practices

  • Never hardcode API keys in client-side code
  • Store keys using environment variables
  • Rotate API keys regularly
  • Use different keys for different environments

Environment Variables Example

# .env file
PHOTO_RESTORE_API_KEY=sk-your-api-key-here
// Use in code
const apiKey = process.env.PHOTO_RESTORE_API_KEY;