Link Search Menu Expand Document

Example code

To get started quickly, take a look at our example code for generating images.

Live demo Get an API Key

Using an AI coding assistant?

Skip writing code entirely. Connect our MCP Server to generate images directly from Cursor or Claude Code.


Works with any programming language

The HTML/CSS to Image API is a simple REST API. If your language can make an HTTP request, it can generate images.

We provide example code for popular languages, but the API works the same way everywhere:

  1. Send a POST request to https://hcti.io/v1/image
  2. Include your HTML/CSS in the request body
  3. Authenticate with HTTP Basic Auth
  4. Receive a JSON response with your image URL

The API request

Here’s what a request to the API looks like:

Property Description
Endpoint https://hcti.io/v1/image
Method POST
Content-Type application/json
Authentication HTTP Basic Auth (User ID + API Key)

Request body (JSON)

{
  "html": "<div class='box'>Hello, world!</div>",
  "css": ".box { padding: 20px; background: #03B875; color: white; }"
}

Response

{
  "url": "https://hcti.io/v1/image/be4c5118-fe19-462b-a49e-48cf72697a9d"
}

The returned URL is your generated image. Append .png, .jpg, or .webp to the URL to get different formats.


Quick reference with cURL

The simplest way to test the API:

curl -X POST https://hcti.io/v1/image \
  -u 'your-user-id:your-api-key' \
  -H 'Content-Type: application/json' \
  -d '{"html": "<h1>Hello!</h1>"}'

Available parameters

Parameter Required Description
html Yes* The HTML to render
css No CSS styles for your HTML
url Yes* URL of a webpage to screenshot
google_fonts No Google Fonts to load (comma separated)
ms_delay No Milliseconds to wait before capture
device_scale No Device scale factor (1-3) for retina images
full_screen No Capture the full scrollable page
selector No CSS selector to screenshot a specific element

*Either html or url is required.

For full parameter documentation, see Parameters.


Choose your language

Select your programming language below to see a complete working example:


Table of contents


Back to top

Built with extensive integration tests and serious care for developer happiness.
© 2018-2025 Code Happy, LLC.

Page last modified: Jan 10 2026 at 06:56 PM.

Edit this page on GitHub.