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

ParameterTypeDescription
urlstringThe URL of the webpage to extract from
captureType'html'Set to 'html' for content extraction
format'html' | 'json' | 'markdown'Output format for the content
waitDurationnumberTime to wait for dynamic content (seconds)
selectorstringCSS selector to extract specific element
customCSSstringCustom CSS to inject before extraction
customJSstringCustom 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});
14
15const 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.