Link Search Menu Expand Document

Screenshot a Tweet

Use the HTML/CSS to Image API to generate images of tweets.


Problems with Twitter screenshots

The Twitter embed API has changed and is blocking many requests. This has resulted in screenshots often returning blank images. We currently do not have a solution, but are working on it.

How it works

To generate a screenshot of a Tweet, we can make use of the Twitter embed API.

For the image to work, make sure you set the selector param to .twitter-tweet and ms_delay to 1500. This gives the embed extra time to load and has the API properly crop the tweet.

Example code

Copy this example, and swap out the href to create an image of any tweet you’d like.

Generate a screenshot of a tweet automatically

HTML

<blockquote class="twitter-tweet" style="width: 400px;" data-dnt="true">
<p lang="en" dir="ltr"></p>

<a href="https://twitter.com/fortnitegame/status/1253524351376330752"></a>

</blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

Important: set these parameters when creating the image.

  • selector: .twitter-tweet
  • ms_delay: 1500

Try it yourself


Need help?

Talk to a human. Please email us support@htmlcsstoimage.com with any questions and we’ll gladly help you get started.


Back to top

Built with extensive integration tests and serious care for developer happiness.
© 2018-2024 Code Happy, LLC.

Page last modified: Apr 9 2024 at 11:04 PM.

Edit this page on GitHub.