stdray.Twitter
1.2.2
See the version list below for details.
dotnet add package stdray.Twitter --version 1.2.2
NuGet\Install-Package stdray.Twitter -Version 1.2.2
<PackageReference Include="stdray.Twitter" Version="1.2.2" />
<PackageVersion Include="stdray.Twitter" Version="1.2.2" />
<PackageReference Include="stdray.Twitter" />
paket add stdray.Twitter --version 1.2.2
#r "nuget: stdray.Twitter, 1.2.2"
#:package stdray.Twitter@1.2.2
#addin nuget:?package=stdray.Twitter&version=1.2.2
#tool nuget:?package=stdray.Twitter&version=1.2.2
stdray.Twitter
A C# library for retrieving Twitter/X.com tweet content by ID.
Description
stdray.Twitter provides a simple API for retrieving tweet data, including text and media files (images and videos).
The library uses an authentication mechanism similar to yt-dlp to work with Twitter/X GraphQL API.
Features
- Retrieve tweet data by ID
- Extract tweet text
- Extract media files (images, videos, animated GIFs)
- For videos: get all variants with bitrate and resolution information
- Automatic resolution extraction from URL if not specified in JSON
Usage
using stdray.Twitter;
using System.Linq;
var client = new TwitterClient(new HttpClient());
var tweet = await client.GetTweetById("1989071142053900550");
var photos = tweet.Media.OfType<PhotoMedia>().ToArray();
var videos = tweet.Media.OfType<VideoMedia>().ToArray();
Console.WriteLine($"Text: {tweet.Text}");
Console.WriteLine($"Photos: {photos.Length}");
Console.WriteLine($"Videos/GIFs: {videos.Length}");
foreach (PhotoMedia photo in photos)
{
Console.WriteLine($"Image: {photo.Url}");
}
foreach (VideoMedia video in videos)
{
var bestVariant = video.Variants
.OrderByDescending(v => v.Bitrate ?? 0)
.First();
var kind = video.Type == MediaType.AnimatedGif ? "GIF" : "Video";
Console.WriteLine($"{kind}: {bestVariant.Url} ({bestVariant.Width}x{bestVariant.Height})");
}
Source
This library is based on the authentication mechanism and Twitter API logic from the yt-dlp project.
Source code reference:
Requirements
- .NET 8.0
Building
This project uses Cake build automation system with GitVersion for semantic versioning. You can build the project in several ways:
Using Cake (Cross-platform)
Prerequisites: Install .NET SDK 8.0 or later
Run the build:
# On Windows .\build.ps1 # On macOS/Linux chmod +x build.sh ./build.sh
Using .NET CLI directly
# Restore packages
dotnet restore
# Build the solution
dotnet build -c Release
# Run tests
dotnet test -c Release
# Pack the NuGet package
dotnet pack -c Release
Note for AI agents: When running commands in PowerShell (pwsh), avoid using
&&as a separator (e.g.,cd D:/prj/github/stdray/stdray-twitter && git status -sb). Use;if you need to chain commands in pwsh.
Build Targets
The Cake build script supports the following targets:
Default: Cleans, restores, builds and runs testsBuild: Builds the solutionTest: Runs unit testsPack: Creates NuGet packagesPublish: Publishes NuGet packages to nuget.orgCI: Full CI pipeline (build, test, pack, publish)
Example: .\build.ps1 -Target="Pack" -Configuration="Release"
CI/CD
This project uses GitHub Actions for continuous integration and deployment:
- Pull requests trigger build and test validation
- Commits to the
mainbranch trigger the full CI/CD pipeline including NuGet package publishing
License
See LICENSE file (if applicable).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- No dependencies.
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.2.3-ci.1 | 43 | 3/3/2026 |
| 1.2.2 | 477 | 12/10/2025 |
| 1.1.2-ci.12 | 422 | 12/10/2025 |
| 1.1.2-ci.11 | 396 | 12/9/2025 |
| 1.1.2-ci.10 | 91 | 11/29/2025 |
| 1.1.2-ci.9 | 68 | 11/29/2025 |
| 1.1.2-ci.8 | 89 | 11/29/2025 |
| 1.1.2-ci.7 | 68 | 11/29/2025 |
| 1.0.0 | 122 | 11/29/2025 |