Documentation

Photo Restoration API

Restore old photos using AI technology

The Photo Restoration API allows you to restore old, damaged photos using advanced AI technology. This endpoint processes images and returns a restored version. Experience the powerful AI photo restoration feature of Restore Old Photos.

Endpoint

POST /api/api-call/photo-restore

Authentication

Requires a valid API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Request

Headers

HeaderRequiredDescription
Content-TypeYesMust be application/json
AuthorizationYesYour API key in format Bearer YOUR_API_KEY

Body Parameters

ParameterTypeRequiredDescription
imageUrlstringYesURL of the image to restore (must be publicly accessible)

Request Example

{
  "imageUrl": "https://example.com/old-photo.jpg"
}

Response

Success Response (200)

API returns the URL or base64 string of the restored image. The platform automatically handles all stream types, and the output field is always a URL or base64 string.

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

or:

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

Description:

  • Output is the URL of the image (recommended) or base64 string (for partial images/large files)
  • No stream object is returned, users can directly use it for img tags or download

Error Responses

400 Bad Request

{
  "message": "Invalid input"
}

401 Unauthorized

{
  "message": "Invalid or expired API key"
}

402 Payment Required

{
  "message": "Insufficient credits"
}

500 Internal Server Error

{
  "message": "Service error"
}

429 Too Many Requests

{
  "message": "Rate limit exceeded. Please try again later."
}

Rate Limits

  • Limit: 100 requests per hour per API key
  • Window: 60 minutes
  • Response: 429 Too Many Requests when exceeded

Usage Examples

JavaScript/Node.js

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) {
      const error = await response.text();
      throw new Error(`API Error: ${response.status} - ${error}`);
    }
 
    const result = await response.json();
    
    // Output is always a string (URL or base64)
    if (result.output.startsWith('data:image')) {
      // Base64 image data
      return result.output;
    } else if (result.output.startsWith('http')) {
      // Image URL
      return result.output;
    } else {
      throw new Error('Invalid output format');
    }
  } catch (error) {
    console.error('Error restoring photo:', error);
    throw error;
  }
}
 
// Usage
const restoredImage = await restorePhoto(
  'https://example.com/old-photo.jpg',
  'your-api-key-here'
);
console.log('Restored image:', restoredImage);

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"
  }'

Image Requirements

  • Format: JPG, PNG, WebP
  • Size: Maximum 5MB
  • Accessibility: Image URL must be publicly accessible
  • Content: Must be a valid image file

Processing Time

  • Typical: 10-30 seconds
  • Large images: May take up to 60 seconds

Credits

  • Cost: 1 credit per restoration
  • Deduction: Credits are deducted upon successful processing

Best Practices

  1. Image Quality: Use high-quality images for better results
  2. Error Handling: Always implement proper error handling
  3. Credit Management: Monitor your credit balance regularly
  4. Output Handling: Output is always a string, no stream processing needed

Troubleshooting

Common Issues

401 Unauthorized

  • Check that your API key is correct
  • Ensure the API key is active and not expired

402 Payment Required

  • Add credits to your account
  • Check your current credit balance

400 Bad Request

  • Verify the imageUrl is a valid, accessible URL
  • Ensure the image format is supported

Invalid Output Format

  • Output should always be a string (URL or base64)
  • Check if the API response contains the expected output field

429 Too Many Requests

  • You have exceeded the rate limit of 100 requests per hour
  • Wait for the rate limit window to reset before making more requests

Support

If you encounter issues not covered here, please contact our support team.