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.