Create Image from HTML
Send a POST request to this endpoint to create a new image using custom HTML.
You will need to authenticate to use this API. See authentication.
This endpoint consumes 1 credit per image. The credit is spent when the render starts, and a render that fails costs nothing: its credit is refunded.
Request
POST https://api.ojo.so/v1/image/htmlHeaders
| Header | Value | Description |
|---|---|---|
| Content-Type | text/html | Specify that the request body contains HTML |
| x-viewport-width | number | (Optional) Width of the viewport in pixels (default: 1280) |
| x-viewport-height | number | (Optional) Height of the viewport in pixels (default: 800) |
| x-transparent-background | boolean | (Optional) When set to true, generates the image with a transparent background. Defaults to false if not specified. |
Request Body
The request body should contain the HTML content you want to render as an image.
You can also send JSON with Content-Type: application/json. A value in the body wins over its
header.
| Field | Type | Description |
|---|---|---|
| html | string | The HTML to render |
| viewportWidth | number | (Optional) Width of the viewport in pixels (default: 1280) |
| viewportHeight | number | (Optional) Height of the viewport in pixels (default: 800) |
| transparentBackground | boolean | (Optional) When true, renders without a background colour |
cURL
curl --request POST \
--url https://api.ojo.so/v1/image/html \
--header 'Authorization: Bearer <your API key>' \
--header 'Content-Type: text/html' \
--header 'x-viewport-width: 1500' \
--header 'x-viewport-height: 1000' \
--data '<html><body><div id="main-content"><h1>Hello, World!</h1></div></body></html>'Response
200
Everything went as planned and your image is generated.
{
"id": "image-id",
"imageUrl": "https://example.com/path/to/image.png",
"createdAt": "2023-08-29T12:34:56Z"
}