- Docs
- Example code
- Curl
Curl
Generate an image with cURL
Section titled “Generate an image with cURL”Run this command in your terminal to generate an image using the API.
For more details on how this works, see Creating an image.
# Replace UserID and APIKey with your credentials from the dashboard https://htmlcsstoimage.com/dashboardcurl -X POST https://hcti.io/v1/image -u 'UserID:APIKey'\ -d html="<div class='ping'>Pong ✅</div>" \ -d css=".ping { padding: 20px; font-family: 'sans-serif'; }"Response
Section titled “Response”The API will return a json payload with the URL to your new image.
{ "url":"https://hcti.io/v1/image/1eecf460-e2e5-4db1-9db6-cf862c34a744" }Advanced example
Section titled “Advanced example”Here we use additional parameters. Note that each line ends with a \.
# Replace UserID and APIKey with your credentials from the dashboard https://htmlcsstoimage.com/dashboardcurl -X POST https://hcti.io/v1/image -u 'UserID:APIKey'\ -d html="<div class='ping'>Pong ✅</div>" \ -d css=".ping { padding: 20px; font-family: 'sans-serif'; }" \ -d ms_delay=1000 \ -d selector=".ping"Loading in contents from a file
Section titled “Loading in contents from a file”In this example, we grab the contents of a local HTML file and pass them in to the html param.
Use --data-urlencode html@path/to/file.html to read and encode the HTML file directly.
curl -X POST https://hcti.io/v1/image -u 'UserID:APIKey'\ --data-urlencode html@path/to/file.html \ -d css=".ping { padding: 20px; font-family: 'sans-serif'; }"Checking a design in CI
Section titled “Checking a design in CI”The HTML-file example can also run in a build pipeline. Generate an HTML fixture for a receipt or social card, send the file to HCTI, and attach the returned image URL to the build output for review. This gives reviewers a rendered example without adding a browser installation to the CI runner.
Keep the fixture’s data, viewport, fonts, and CSS stable so changes are easier to compare. Send its stylesheet with the request or use publicly accessible absolute asset URLs; HCTI cannot read files beside the HTML on your runner. This is useful for reviewing a design, but the render alone doesn’t assert that it matches an approved baseline.
Need help?
Talk to a human. Email support@htmlcsstoimage.com and we’ll help you get started.