HTML Content API Reference
The HTML Content API allows you to extract clean HTML content from any webpage with preserved DOM structure.
Extract Content
Endpoint
bash
01POST https://api.screenshotapi.io/v1/capture
Request Options
Parameter | Type | Description |
---|---|---|
url | string | The URL of the webpage to extract from |
captureType | 'html' | Set to 'html' for content extraction |
format | 'html' | 'json' | 'markdown' | Output format for the content |
waitDuration | number | Time to wait for dynamic content (seconds) |
selector | string | CSS selector to extract specific element |
customCSS | string | Custom CSS to inject before extraction |
customJS | string | Custom JavaScript to execute before extraction |
Response
typescript
01interface HTMLResponse {02 content: string;03 mime_type: string;04 size: number;05 created_at: string;06}
Example
javascript
01const response = await fetch('https://api.screenshotapi.io/v1/capture', {02 method: 'POST',03 headers: {04 'Content-Type': 'application/json',05 'Authorization': 'Bearer your_api_key'06 },07 body: JSON.stringify({08 url: 'https://example.com',09 captureType: 'html',10 format: 'html',11 selector: '#main-content'12 })13});1415const data = await response.json();16console.log(data.content);
Content Formats
The API supports three output formats for content extraction:
- HTML: Raw HTML content with preserved structure
- JSON: Structured data extraction in JSON format
- Markdown: Converted content in Markdown format
Ready to Get Started?
Get your API key now and start capturing screenshots in minutes.