--- layout: page title: Python - HTML to Image Example parent: Example code permalink: /example-code/python/ description: >- Convert HTML to an image (png, jpg or webp) with Python + the HTML/CSS to Image API. Renders images exactly like Google Chrome. --- {% include intro.md language="Python" %} ```python # pip3 install requests import requests HCTI_API_ENDPOINT = "https://hcti.io/v1/image" # Retrieve these from https://htmlcsstoimage.com/dashboard HCTI_API_USER_ID = 'your-user-id' HCTI_API_KEY = 'your-api-key' data = { 'html': "