- Docs
- Guides
- Social media
- Twitter/X screenshot
Twitter/X screenshot
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.
Method 1: URL Screenshot (Recommended)
Section titled “Method 1: URL Screenshot (Recommended)”The simplest approach is to use the url parameter to directly screenshot the tweet on x.com.
Example
Section titled “Example”Pass the tweet URL directly to the API with the selector parameter set to article to crop to just the tweet.
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 }'Result
Section titled “Result”Parameters
Section titled “Parameters”| 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 |
Method 2: HTML Embed
Section titled “Method 2: HTML Embed”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>Result
Section titled “Result”Parameters for HTML Embed
Section titled “Parameters for HTML Embed”| Parameter | Value | Description |
|---|---|---|
selector |
.twitter-tweet |
Crops to the rendered tweet widget |
ms_delay |
3000 |
Gives the embed time to load via JavaScript |
Choosing the Right Method
Section titled “Choosing the Right Method”| 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 |
Getting the Tweet URL
Section titled “Getting the Tweet URL”To get the URL of any tweet:
- Click on the tweet to open it
- Copy the URL from your browser’s address bar
- 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.