yoni56.XSharpSdk
1.0.0
dotnet add package yoni56.XSharpSdk --version 1.0.0
NuGet\Install-Package yoni56.XSharpSdk -Version 1.0.0
<PackageReference Include="yoni56.XSharpSdk" Version="1.0.0" />
<PackageVersion Include="yoni56.XSharpSdk" Version="1.0.0" />
<PackageReference Include="yoni56.XSharpSdk" />
paket add yoni56.XSharpSdk --version 1.0.0
#r "nuget: yoni56.XSharpSdk, 1.0.0"
#:package yoni56.XSharpSdk@1.0.0
#addin nuget:?package=yoni56.XSharpSdk&version=1.0.0
#tool nuget:?package=yoni56.XSharpSdk&version=1.0.0
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
*Dtocontracts (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.Apicurrently serves as the DI composition root only; add Controllers or Minimal API endpoints underXSharp.Apito 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 | Versions 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. |
-
net10.0
- XSharp.Application (>= 1.0.0)
- XSharp.Domain (>= 1.0.0)
- XSharp.Infrastructure (>= 1.0.0)
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 |