TiktokExplode.Extensions.DependencyInjection
1.2.2
dotnet add package TiktokExplode.Extensions.DependencyInjection --version 1.2.2
NuGet\Install-Package TiktokExplode.Extensions.DependencyInjection -Version 1.2.2
<PackageReference Include="TiktokExplode.Extensions.DependencyInjection" Version="1.2.2" />
<PackageVersion Include="TiktokExplode.Extensions.DependencyInjection" Version="1.2.2" />
<PackageReference Include="TiktokExplode.Extensions.DependencyInjection" />
paket add TiktokExplode.Extensions.DependencyInjection --version 1.2.2
#r "nuget: TiktokExplode.Extensions.DependencyInjection, 1.2.2"
#:package TiktokExplode.Extensions.DependencyInjection@1.2.2
#addin nuget:?package=TiktokExplode.Extensions.DependencyInjection&version=1.2.2
#tool nuget:?package=TiktokExplode.Extensions.DependencyInjection&version=1.2.2
TiktokExplode.Extensions.DependencyInjection
Microsoft.Extensions.DependencyInjection integration for TiktokExplode.
Provides AddTiktokExplode() — a fluent extension method on IServiceCollection that registers IVideoClient and optionally ISearchClient, and lets you choose independently between the Playwright or HTTP fetcher strategy for page fetching and search.
Installation
dotnet add package TiktokExplode.Extensions.DependencyInjection
Usage
// Default — Playwright fetcher for page fetching, all defaults
services.AddTiktokExplode();
// Playwright fetcher with a visible browser window (useful for debugging)
services.AddTiktokExplode(b => b
.UsePlaywrightFetcher(o => o.Headless = false));
// HTTP fetcher for page fetching (faster, no browser dependency)
// with Playwright search support — recommended setup
services.AddTiktokExplode(b => b
.UseHttpFetcher()
.UsePlaywrightSearch(o => o.BrowserChannel = "msedge"));
// HTTP fetcher only — no search support
// Note: ISearchClient is NOT registered without UsePlaywrightSearch
services.AddTiktokExplode(b => b
.UseHttpFetcher(o => o.WarmupDelay = TimeSpan.Zero)
.ConfigureTiktok(o => o.MaxWafRetries = 5));
Then inject IVideoClient or ISearchClient normally:
public class MyService(IVideoClient client, ISearchClient search)
{
public async Task<string> GetTitleAsync(string url)
{
var video = await client.GetVideoAsync(url);
return video.Description;
}
public async IAsyncEnumerable<string> SearchTitlesAsync(string keyword)
{
await foreach (var video in search.SearchAsync(keyword))
yield return video.Description;
}
}
Registered services
| Service | Implementation | Lifetime | Condition |
|---|---|---|---|
IVideoClient |
TiktokClient |
Singleton | Always |
ISearchClient |
TiktokSearchClient |
Singleton | UsePlaywrightSearch only |
IPageFetcher |
PlaywrightFetcher or HttpFetcher |
Singleton | Always |
ISearchFetcher |
PlaywrightSearchFetcher |
Singleton | UsePlaywrightSearch only |
TiktokDownloadClient |
— | Singleton | Always (shared HTTP session) |
TiktokOptions |
— | Singleton | Always |
PlaywrightFetcherOptions or HttpFetcherOptions |
— | Singleton | Always |
Important:
ISearchClientandISearchFetcherare only registered whenUsePlaywrightSearchis called. TikTok's search API requires a real browser to sign requests — it cannot be replicated with plain HTTP. If you omitUsePlaywrightSearchand attempt to injectISearchClient, the DI container will throw a resolution error at runtime.
Cookie sharing:
TiktokDownloadClientis registered as a singleton shared betweenIVideoClientandISearchClient. Cookies obtained during a search session are automatically available when downloading, avoiding403 Forbiddenerrors.
Builder API
| Method | Description |
|---|---|
ConfigureTiktok(Action<TiktokOptions>?) |
Configures WAF retry count and base delay |
UsePlaywrightFetcher(Action<PlaywrightFetcherOptions>?) |
Uses a real Chromium browser as IPageFetcher (default). Does not register search services |
UseHttpFetcher(Action<HttpFetcherOptions>?) |
Uses a plain HttpClient as IPageFetcher — faster start, no browser dependency, may be WAF-blocked |
UsePlaywrightSearch(Action<PlaywrightFetcherOptions>?) |
Registers ISearchFetcher and ISearchClient using Playwright. Independent of the page fetcher choice |
Note:
UsePlaywrightFetcherandUseHttpFetcherare mutually exclusive — the last one called wins.UsePlaywrightSearchis independent and can be combined with either.
Related packages
| Package | Description |
|---|---|
TiktokExplode |
Domain layer — models, interfaces, exceptions |
TiktokExplode.Infrastructure |
HTTP + Playwright fetchers, parser, download client |
TiktokExplode.All |
Meta-package — installs domain + infrastructure together |
License
MIT — see LICENSE for details.
| 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 is compatible. 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
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.5)
- TiktokExplode (>= 1.2.2)
- TiktokExplode.Infrastructure (>= 1.2.2)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.5)
- TiktokExplode (>= 1.2.2)
- TiktokExplode.Infrastructure (>= 1.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.