Skip to content
HTML/CSS to ImageDocs

Use the HTML/CSS to Image API to generate images of tweets and posts on X.

There are two ways to capture a screenshot of a tweet: using the URL method (recommended) or the HTML embed method.

The simplest approach is to use the url parameter to directly screenshot the tweet on x.com.

Pass the tweet URL directly to the API with the selector parameter set to article to crop to just the tweet.

Terminal window
curl -X POST https://hcti.io/v1/image -u 'UserID:APIKey' \
-H "Content-Type: application/json" \
-d '{
"url": "https://x.com/usahockey/status/2006109366827597923",
"selector": "article",
"ms_delay": 3000,
"device_scale": 2
}'
Screenshot of a tweet using the URL method
Parameter Value Description
url Tweet URL The full URL to the tweet on x.com (e.g., https://x.com/username/status/123456789)
selector article Crops the image to just the tweet content
ms_delay 3000 Gives the page time to fully load (3 seconds recommended)
device_scale 2 Optional. Higher resolution image

You can also use the X/Twitter embed widget to render a tweet. This gives you a card-style appearance.

HTML

<blockquote class="twitter-tweet" data-dnt="true">
<a href="https://twitter.com/usahockey/status/2006109366827597923"></a>
</blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
Screenshot of a tweet using the HTML embed method
Parameter Value Description
selector .twitter-tweet Crops to the rendered tweet widget
ms_delay 3000 Gives the embed time to load via JavaScript
Method Best For
URL Screenshot Full tweet appearance as seen on x.com, including engagement metrics
HTML Embed Card-style appearance with X branding, “Follow” button, and replies link

To get the URL of any tweet:

  1. Click on the tweet to open it
  2. Copy the URL from your browser’s address bar
  3. The URL format is: https://x.com/username/status/tweet_id

Need help?

Talk to a human. Email support@htmlcsstoimage.com and we’ll help you get started.