yoni56.InstagramSharpSdk 1.0.3

dotnet add package yoni56.InstagramSharpSdk --version 1.0.3
                    
NuGet\Install-Package yoni56.InstagramSharpSdk -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="yoni56.InstagramSharpSdk" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="yoni56.InstagramSharpSdk" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="yoni56.InstagramSharpSdk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add yoni56.InstagramSharpSdk --version 1.0.3
                    
#r "nuget: yoni56.InstagramSharpSdk, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package yoni56.InstagramSharpSdk@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=yoni56.InstagramSharpSdk&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=yoni56.InstagramSharpSdk&version=1.0.3
                    
Install as a Cake Tool

InstagramSharp

A simple, strongly-typed C# SDK that wraps Instagram's Graph API, built for .NET 10. InstagramSharp makes it easy to authenticate with Instagram, and to work with users, media, comments, hashtags, insights, stories, mentions, business discovery, messaging, and content publishing — all through a clean, testable, interface-based API.

Features

  • OAuth authentication — build authorization URLs, exchange codes for tokens, and manage short-/long-lived token exchange & refresh.
  • Users — fetch user profile information.
  • Media — get single media items or list a user's media.
  • Comments — create, get, list, delete comments, and manage replies.
  • Hashtags — search hashtags, get hashtag info, recent/top media for a hashtag.
  • Insights — retrieve account-level and media-level insights/metrics.
  • Stories — retrieve a user's active stories.
  • Mentions — get mentioned comments/media and reply to mentions.
  • Business Discovery — look up public business/creator account data and send messages.
  • Publishing — create media containers, check container status, and publish content.
  • Container — inspect container objects.

The library is organized as one interface (I*) and one implementation (T*) per feature area, all exposed through a single IInstagramClient entry point.

Installation

InstagramSharp is distributed as a NuGet package:

dotnet add package yoni56.InstagramSharpSdk

Requirements

  • .NET 10 (or a compatible target framework)
  • A Meta/Instagram Graph API access token (and, for OAuth flows, an app ID, app secret, and redirect URI)

Getting Started

Create a client

using InstagramSharp;

var client = new InstagramClient("YOUR_ACCESS_TOKEN");

InstagramClient implements IInstagramClient and exposes each feature area as a property:

public interface IInstagramClient
{
	IUsers Users { get; }
	IMedia Media { get; }
	IComments Comments { get; }
	IInsights Insights { get; }
	IStories Stories { get; }
	IHashtags Hashtags { get; }
	IPublishing Publishing { get; }
	IMentions Mentions { get; }
	IBusinessDiscovery BusinessDiscovery { get; }
	IMessaging Messaging { get; }

	InstagramOAuth CreateInstagramOAuth(string appId, string appSecret, string redirectUri);
}

Internally, the client targets the Facebook Graph API at https://graph.facebook.com/v23.0 and automatically attaches your access token to every request.

Example: Get user info

var response = client.Users.Get(new UserGetRequest
{
	// request properties, e.g. UserId / Fields
});

if (response.IsSuccessful)
{
	var user = response.Data;
}

Example: List media

var response = client.Media.List(new MediaListRequest
{
	// request properties
});

Example: Publish content

// 1. Create a media container
var container = client.Publishing.Create(new ContainerCreateRequest
{
	// e.g. ImageUrl, Caption, etc.
});

// 2. Check container status
var status = client.Publishing.Get(new ContainerStatusRequest
{
	// container id
});

// 3. Publish the container
var published = client.Publishing.Publish(new PublishRequest
{
	// container id
});

Every call returns a RestResponse<T> (from RestSharp), so you can inspect IsSuccessful, StatusCode, Content, and the strongly-typed Data payload.

OAuth Authentication Flow

InstagramSharp includes an InstagramOAuth helper for handling the full Instagram Basic Display / Graph OAuth flow:

using InstagramSharp;

var oauth = client.CreateInstagramOAuth(appId: "APP_ID", appSecret: "APP_SECRET", redirectUri: "https://yourapp.com/callback");

// 1. Redirect the user to the authorization URL
string authUrl = oauth.BuildAuthorizationUrl(scope: "user_profile,user_media,user_insights");

// 2. Exchange the returned "code" for a short-lived access token
var tokenResponse = await oauth.ExchangeCodeForTokenAsync(code);

// 3. Exchange the short-lived token for a long-lived token
var longLivedToken = await oauth.ExchangeShortLivedForLongLivedTokenAsync(tokenResponse.AccessToken);

// 4. Refresh a long-lived token before it expires
var refreshedToken = await oauth.RefreshLongLivedTokenAsync(longLivedToken.AccessToken);

If a request fails, an AuthException is thrown containing the error message and raw response content.

Project Structure

src/
├── BusinessDiscovery/   # Public account discovery + messaging
├── Comments/            # Comment CRUD, replies, listing
├── Container/           # Media container inspection
├── Hashtags/            # Hashtag search & media
├── Insights/            # Account & media insights
├── Media/               # Media get/list
├── Mentions/            # Mentioned comments/media, mention replies
├── OAuth/               # InstagramOAuth authentication flow
├── Publishing/          # Container create/status + publish
├── Stories/             # Active stories retrieval
├── Users/                # User profile retrieval
├── IInstagramClient.cs  # Main client interface
└── InstagramClient.cs   # Main client implementation

Each feature folder follows the same convention:

  • I<Feature>.cs — public interface describing available operations
  • T<Feature>.cs — concrete implementation using RestSharp
  • Models/Request/ — strongly-typed request models
  • Models/Response/ — strongly-typed response models

Dependencies

License

This project is licensed under the MIT License.

Repository

Source code is hosted on GitHub: ydahan56/InstagramSharp

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 84 8/24/2026
1.0.1 103 6/17/2026
1.0.0 75 6/5/2026