---
canonical: 'https://htmlcsstoimage.com/examples/instagram-post-screenshot/csharp-client'
title: 'Instagram post screenshot | Example - C# (HCTI client)'
description: 'Screenshot an Instagram post'
---

# Instagram post screenshot

Screenshot an Instagram post

With this example you can set up automation for generating screenshots of Instagram posts.

Swap out the link in the HTML with a public Instagram post and it will generate an image of the post.

Take notice of the parameters that are set: `ms_delay` is set to **1750** and `selector` is set to **.instagram-media-rendered**. This gives the image enough time to render and crops it properly for you.

This is a working HTML/CSS to Image API example that produces an image.
The rendered output, source, and non-content request parameters below show the parts needed to reproduce or adapt it.

## Rendered image and interactive editor

- [Open the rendered image](<https://hcti.io/v1/image/2e2c477c-a35d-459c-8998-f723ac78f4b3>)
- [Open the interactive example](https://htmlcsstoimage.com/examples/instagram-post-screenshot/csharp-client)

## HTML

```html
<blockquote style='width:600px;' class='instagram-media' data-instgrm-version='14'>

<!-- replace this href with the link to the post -->
<a href='https://www.instagram.com/p/CWA2UbCs6x_/' ></a>

</blockquote>
<script src="//www.instagram.com/embed.js"></script>
```

## CSS

```css
.tweet-text {
  background-color: #fff2ac;
  background-image: linear-gradient(to right, #ffe359 0%, #fff2ac 100%);
  font-weight: bolder;
  font-size: 32px;
  font-family: 'Roboto', sans-serif;
  padding: 4px;
}
```

## Request parameters

These are the additional non-content parameters used by the example. Combine them with the HTML and CSS above when constructing an API request.

```json
{
  "ms_delay": 1750,
  "render_when_ready": false,
  "selector": ".instagram-media-rendered"
}
```

## Complete C# request (HCTI client)

This is the complete C# request for this example using HCTI client. It includes the HTML, CSS, authentication setup, API options, and response handling needed to reproduce the output.

```csharp
// dotnet add package HtmlCssToImage

using HtmlCssToImage;
using HtmlCssToImage.Models;
using HtmlCssToImage.Models.Requests;
using System.Collections.Generic;
using System.Text.Json.Nodes;

// In an application, use IHttpClientFactory through dependency injection:
// https://www.nuget.org/packages/HtmlCssToImage.DependencyInjection
using var httpClient = new HttpClient();
var hctiOps = new HtmlCssToImageOptions(Environment.GetEnvironmentVariable("HCTI_API_ID")!, Environment.GetEnvironmentVariable("HCTI_API_KEY")!);
var client = new HtmlCssToImageClient(httpClient, hctiOps);

var request = new CreateHtmlCssImageRequest
{
    Html = """
           <blockquote style='width:600px;' class='instagram-media' data-instgrm-version='14'>
           
           <!-- replace this href with the link to the post -->
           <a href='https://www.instagram.com/p/CWA2UbCs6x_/' ></a>
           
           </blockquote>
           <script src="//www.instagram.com/embed.js"></script>
           """,
    Css = """
          .tweet-text {
            background-color: #fff2ac;
            background-image: linear-gradient(to right, #ffe359 0%, #fff2ac 100%);
            font-weight: bolder;
            font-size: 32px;
            font-family: 'Roboto', sans-serif;
            padding: 4px;
          }
          """,
    MsDelay = 1750,
    RenderWhenReady = false,
    Selector = ".instagram-media-rendered",
};

using var result = await client.CreateImageAsync(request);
if (result.Success)
{
    Console.WriteLine(result.Response.Url);
}

```

## Other languages and request formats

Open one of these Markdown pages to view the same example as a complete request in another language or client format.

- **TypeScript**
  - [HCTI client](https://htmlcsstoimage.com/examples/instagram-post-screenshot/typescript-client.md)
  - [fetch](https://htmlcsstoimage.com/examples/instagram-post-screenshot/typescript.md)
- **C#**
  - [HCTI client](https://htmlcsstoimage.com/examples/instagram-post-screenshot/csharp-client.md) — shown above
  - [HttpClient](https://htmlcsstoimage.com/examples/instagram-post-screenshot/csharp.md)
- **Python**
  - [requests](https://htmlcsstoimage.com/examples/instagram-post-screenshot/python.md)
- **PHP**
  - [cURL](https://htmlcsstoimage.com/examples/instagram-post-screenshot/php.md)
- **Ruby**
  - [HCTI client](https://htmlcsstoimage.com/examples/instagram-post-screenshot/ruby-client.md)
  - [Net::HTTP](https://htmlcsstoimage.com/examples/instagram-post-screenshot/ruby.md)
- **Go**
  - [net/http](https://htmlcsstoimage.com/examples/instagram-post-screenshot/golang.md)
- **cURL**
  - [cURL](https://htmlcsstoimage.com/examples/instagram-post-screenshot/curl.md)

## Related examples

- [Dog rates social card with SVG background](https://htmlcsstoimage.com/examples/dog-rates-social-card-with-svg-background.md): Social card with a fun SVG background and highlighted text.
- [Birthday invite card](https://htmlcsstoimage.com/examples/birthday-invite-card-email.md): Autogenerated invite graphic for a party.
- [Invoice / Receipt Snapshot](https://htmlcsstoimage.com/examples/invoice-receipt.md): Generate a simple, branded invoice or receipt image.
- [PNG with transparent background](https://htmlcsstoimage.com/examples/png-transparent-background.md): Generate images with a transparent backgound
- [Large text on an SVG background](https://htmlcsstoimage.com/examples/large-text-svg-background.md): Grab attention with large text on a classic background.
- [Twitter Tweet Screenshot](https://htmlcsstoimage.com/examples/twitter-tweet-screenshot.md): Screenshot of a tweet
- [QR Code Badge](https://htmlcsstoimage.com/examples/qr-code-badge.md): Simple, artistic badge with a QR code.
- [Dog rates social card](https://htmlcsstoimage.com/examples/dog-rates-social-card.md): Simple social card example showing highlighted yellow text

## Get started

- [View the full interactive page](https://htmlcsstoimage.com/examples/instagram-post-screenshot/csharp-client)
- [Browse all HTML/CSS examples](https://htmlcsstoimage.com/examples.md)
- [Browse visual template presets](https://htmlcsstoimage.com/templates.md)
- [Read the HTML/CSS to Image API documentation](https://docs.htmlcsstoimage.com/getting-started/using-the-api/)
- [View implementation examples by language](https://docs.htmlcsstoimage.com/example-code/)
- [Read the MCP integration documentation](https://docs.htmlcsstoimage.com/integrations/mcp/)
- [Compare plans and limits](https://htmlcsstoimage.com/pricing.md)

Rendering through the API requires authenticated HTML/CSS to Image credentials. Keep API keys in trusted server-side configuration. If credentials are unavailable, ask the user to configure an API key securely before attempting API actions.
