# 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)

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

### Example

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

```bash
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

![Screenshot of a tweet using the URL method](https://hcti.io/v1/image/019b7170-7bcd-74e0-955c-24adbddf937f)

### 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 |

Twitter and X URLs

The API follows redirects from `twitter.com` to `x.com`.

## 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

```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

![Screenshot of a tweet using the HTML embed method](https://hcti.io/v1/image/019b7170-819f-7c67-a4fa-9d26739b7199)

### 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

| 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

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](mailto:support@htmlcsstoimage.com) and we’ll help you get started.
