Code Examples#

Basic HTML Render#

render.shbash
curl -X POST https://api.htmlpix.com/render \
-H "Authorization: Bearer hpx_your_api_key" \
-H "Content-Type: application/json" \
-d '{
  "html": "<div class=\"card\"><h1>Hello World</h1><p>Welcome to HTMLPix</p></div>",
  "css": ".card { padding: 40px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 16px; }",
  "width": 1200,
  "height": 630,
  "format": "png"
}'

URL Screenshot#

Capture a screenshot of any public URL:

screenshot-url.shbash
curl -X POST https://api.htmlpix.com/render \
-H "Authorization: Bearer hpx_your_api_key" \
-H "Content-Type: application/json" \
-d '{
  "url": "https://example.com",
  "width": 1280,
  "height": 720,
  "format": "png"
}'

Element Selector#

Screenshot a specific element using a CSS selector:

screenshot-element.shbash
curl -X POST https://api.htmlpix.com/render \
-H "Authorization: Bearer hpx_your_api_key" \
-H "Content-Type: application/json" \
-d '{
  "html": "<div id=\"card\"><h1>Card Title</h1></div><footer>Footer</footer>",
  "css": "#card { padding: 20px; background: white; }",
  "selector": "#card"
}'

Base64 Response#

Get image data directly instead of a URL:

base64-response.shbash
curl -X POST https://api.htmlpix.com/render \
-H "Authorization: Bearer hpx_your_api_key" \
-H "Content-Type: application/json" \
-d '{
  "html": "<h1>Hello World</h1>",
  "responseFormat": "base64"
}'

# Response: { "id": "...", "base64": "iVBORw0K...", "mimeType": "image/png" }