yoni56.XSharpSdk 1.0.0

dotnet add package yoni56.XSharpSdk --version 1.0.0
                    
NuGet\Install-Package yoni56.XSharpSdk -Version 1.0.0
                    
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.XSharpSdk" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="yoni56.XSharpSdk" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="yoni56.XSharpSdk" />
                    
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.XSharpSdk --version 1.0.0
                    
#r "nuget: yoni56.XSharpSdk, 1.0.0"
                    
#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.XSharpSdk@1.0.0
                    
#: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.XSharpSdk&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=yoni56.XSharpSdk&version=1.0.0
                    
Install as a Cake Tool

XSharp

XSharp is a .NET 10 Clean Architecture client SDK for the X (formerly Twitter) API v2. It wraps the vast majority of X's public REST surface — Posts, Users, Likes, Reposts, Quotes, Media, Lists, Spaces, Communities, Community Notes, Direct Messages, Webhooks, X Activity, Usage, Stream Connections, Compliance, Articles, Trends and News — behind clean, testable Application-layer interfaces, with a RestSharp + AutoMapper + Autofac powered Infrastructure implementation that talks to api.x.com.

Solution Layout

The solution (XSharp.slnx) follows Clean Architecture with strict inward-facing dependencies:

XSharp.Domain          <-- no dependencies (entities only)
   ^
XSharp.Application      <-- depends on Domain (DTOs + service interfaces)
   ^
XSharp.Infrastructure   <-- depends on Application + Domain (RestSharp clients, AutoMapper, Autofac)
   ^
XSharp.Api              <-- depends on all three (ASP.NET Core host / composition root)

XSharp.Client           <-- depends on Domain + Application + Infrastructure (packable NuGet SDK)
Project Purpose
XSharp.Domain Plain C# entity/value-object classes representing X API resources (Post, XUser, MediaItem, XList, Space, Community, CommunityNote, DirectMessageEvent, Webhook, ActivitySubscription, UsageRecord, ConnectionRecord, ComplianceJob, Article, Trend, NewsStory). No external dependencies.
XSharp.Application DTOs (request/response records) and service interfaces (IPostsService, IUsersService, ILikesService, etc.) that define the contract for every X API domain. This is what consumers code against.
XSharp.Infrastructure Concrete implementations of every Application interface using RestSharp for HTTP, AutoMapper for mapping wire-format DTOs to Domain entities, and an Autofac module (XApiAutofacModule) for DI registration. Includes OAuth 1.0a signing for chunked media upload and OAuth2 Bearer auth for standard v2 endpoints.
XSharp.Api ASP.NET Core Web API host acting as the composition root — wires up Autofac (AutofacServiceProviderFactory) and the XApiAutofacModule, reads XApi configuration from appsettings.json.
XSharp.Client A packable project (dotnet pack) that bundles Domain + Application + Infrastructure into a single distributable NuGet package (XSharp.Client.nupkg) for consumption outside this repo.

Feature Coverage

Each X API domain is represented by an I*Service interface in XSharp.Application and a matching *Client implementation in XSharp.Infrastructure:

Domain Application Interface Infrastructure Client Highlights
Posts IPostsService PostsClient Create/delete, lookup, search (recent/all), counts, timelines, mentions, home timeline, bookmarks, reposts, quote posts, hide replies
Likes ILikesService LikesClient Liked posts, liking users, like/unlike
Articles IArticlesService ArticlesClient Draft creation, publish
Users IUsersService UsersClient Lookup by id/username, search, me, followers/following, mute/block, affiliates
Direct Messages IDirectMessagesService DirectMessagesClient Send to conversation/user, event lookup, delete
Lists IListsService ListsClient CRUD, members, memberships, pinned/followed lists
Spaces ISpacesService SpacesClient Lookup, by creator, buyers, posts, search
Communities ICommunitiesService CommunitiesClient Lookup, search
Community Notes ICommunityNotesService CommunityNotesClient Eligible posts, written notes, create/delete/evaluate
Media IMediaService MediaClient Chunked upload (INIT/APPEND/FINALIZE/STATUS) via OAuth 1.0a, metadata
Activity IActivityService ActivityClient Streaming activity feed, subscription CRUD
Usage IUsageService UsageClient Tweet usage/cap reporting
Stream Connections IStreamConnectionsService StreamConnectionsClient Connection history, termination
Compliance IComplianceService ComplianceClient Batch compliance jobs, compliance streams
Webhooks IWebhooksService WebhooksClient CRUD, validation, replay jobs
Trends ITrendsService TrendsClient By WOEID, personalized trends
News INewsService NewsClient Lookup by id, search

Technology Stack

  • .NET 10 / C#
  • RestSharp — HTTP transport for all X API calls (XApiRestClientBase)
  • AutoMapper — maps wire-format *Dto contracts (XSharp.Infrastructure/Contracts) to Domain entities (XApiMappingProfile)
  • Autofac — dependency injection container, wired into the ASP.NET Core host via Autofac.Extensions.DependencyInjection
  • OAuth 1.0a (OAuth1Signer) — required for classic chunked media upload endpoints
  • OAuth2 Bearer (XApiBearerAuthenticator) — used for all standard /2/... JSON endpoints

Configuration

X API credentials are configured under the XApi section (see XSharp.Api/appsettings.json):

{
  "XApi": {
	"BaseUrl": "https://api.x.com",
	"UploadBaseUrl": "https://upload.twitter.com",
	"BearerToken": "",
	"ConsumerKey": "",
	"ConsumerSecret": "",
	"AccessToken": "",
	"AccessTokenSecret": ""
  }
}
  • BearerToken — used for OAuth2 App-only / user-context Bearer authentication on /2/... endpoints.
  • ConsumerKey / ConsumerSecret / AccessToken / AccessTokenSecret — used for OAuth 1.0a signing of classic chunked media upload requests (upload.twitter.com).

Building

dotnet build XSharp.slnx

Running the API host

dotnet run --project XSharp.Api\XSharp.Api.csproj

Note: XSharp.Api currently serves as the DI composition root only; add Controllers or Minimal API endpoints under XSharp.Api to expose the registered services over HTTP.

Packing the client SDK

XSharp.Client bundles XSharp.Domain, XSharp.Application and XSharp.Infrastructure into a single NuGet package:

dotnet pack XSharp.Client\XSharp.Client.csproj -c Release

Output: XSharp.Client\bin\Release\XSharp.Client.<version>.nupkg (plus a .snupkg symbol package).

Consuming a Service

All services are resolved via Autofac using their Application-layer interface, e.g.:

public sealed class MyFeature
{
	private readonly IPostsService _posts;

	public MyFeature(IPostsService posts) => _posts = posts;

	public async Task<string> CreateTweetAsync(string text)
	{
		var result = await _posts.CreatePostAsync(new CreatePostRequest(text));
		return result.Id;
	}
}

Project Dependency Graph

XSharp.Domain
   ↑
XSharp.Application
   ↑
XSharp.Infrastructure  ──uses──> RestSharp, AutoMapper, Autofac
   ↑
XSharp.Api  /  XSharp.Client
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.0 111 8/26/2026