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.
Request
POST https://api.ojo.so/v1/image/html
Headers
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) |
Request Body
The request body should contain the HTML content you want to render as an image.
curl --request POST \
--url https://api.ojo.so/v1/image/html \
--header 'Authorization: Bearer <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
Everything went as planned and your image is generated.
{
"id": "image-uuid",
"imageUrl": "https://example.com/path/to/image.png",
"createdAt": "2023-08-29T12:34:56Z"
}