page_shot / README.md
CatPtain's picture
Upload 11 files
0b2f2ef verified
|
raw
history blame
4.2 kB
metadata
title: Page Screenshot API
emoji: πŸ“Έ
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
license: mit

πŸ“Έ Page Screenshot API

Professional web page screenshot service built with Node.js and Puppeteer, optimized for Hugging Face Spaces.

πŸš€ Live Demo

  • API Endpoint: https://your-username-page-shot.hf.space/screenshot
  • Demo Interface: https://your-username-page-shot.hf.space/demo
  • Health Check: https://your-username-page-shot.hf.space/

πŸ” Access Control

This API uses Hugging Face system-level authentication:

Public Spaces

  • Open access for all users
  • Rate limited to 100 requests per 15 minutes
  • Perfect for demos and testing

Private Spaces

  • Requires valid Hugging Face access token
  • Access controlled by HF platform automatically
  • Higher security for production use

πŸ“– API Usage

Public Space Access

curl -X POST https://your-space.hf.space/screenshot \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "width": 1280, "height": 720}' \
  --output screenshot.jpg

Private Space Access

curl -X POST https://your-space.hf.space/screenshot \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer hf_your_token_here" \
  -d '{"url": "https://example.com", "width": 1280, "height": 720}' \
  --output screenshot.jpg

JavaScript Example

const response = await fetch('https://your-space.hf.space/screenshot', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    // Add this line only for private spaces:
    // 'Authorization': 'Bearer hf_your_token_here'
  },
  body: JSON.stringify({
    url: 'https://example.com',
    width: 1280,
    height: 720,
    quality: 80
  })
});

const imageBlob = await response.blob();

πŸ“Š Parameters

Parameter Type Default Range Description
url string required - Target webpage URL
width number 1280 100-1600 Screenshot width in pixels
height number 720 100-1200 Screenshot height in pixels
quality number 75 10-100 JPEG quality percentage

πŸ”„ Response Examples

Success Response

HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 245760

[Binary JPEG data]

Error Response

{
  "error": "Failed to capture screenshot",
  "message": "Navigation timeout exceeded"
}

Server Busy Response

{
  "status": "busy",
  "error": "Server is currently overloaded",
  "cpuUsage": "96%",
  "queueLength": 3
}

πŸ› οΈ Features

  • βœ… Queue Management - Handles concurrent requests efficiently
  • βœ… CPU Monitoring - Automatic load balancing
  • βœ… Rate Limiting - Prevents abuse
  • βœ… HF Authentication - Integrated with HuggingFace platform
  • βœ… Error Handling - Comprehensive error responses
  • βœ… Demo Interface - Built-in testing UI
  • βœ… Health Monitoring - Status endpoint for monitoring

πŸ“ˆ Monitoring

Health Check

curl https://your-space.hf.space/

Server Status

curl https://your-space.hf.space/status

🚨 Rate Limits

Space Type Requests Window
Public 100 15 minutes
Private 100 15 minutes

πŸ”§ Deployment

This application is optimized for Hugging Face Spaces with:

  • Docker-based deployment
  • Automatic dependency management
  • Resource-efficient Chrome configuration
  • Built-in security features
  • HuggingFace platform integration

πŸ”’ Security Notes

  • Private Spaces: Access automatically controlled by HF platform
  • Public Spaces: Open access with rate limiting
  • No API keys needed: Authentication handled by HuggingFace
  • Secure by design: Follows HF Spaces best practices

πŸ“„ License

Proprietary - Commercial use requires license. See LICENSE for details.

🀝 Support

For technical support or questions, please contact the administrator.