SynesthesiaDev.EnkaDotNet 1.1.6.7

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

Enka.DotNet

Enka.DotNet is a C# wrapper for accessing and processing character data from the Enka.Network API. It provides a simple interface to retrieve detailed information about characters, artifacts, weapons, and player profiles for Genshin Impact, Honkai: Star Rail, and Zenless Zone Zero.

NuGet Quality Gate Status Code Smells Reliability Rating Security Rating Maintainability Rating Vulnerabilities

Features

  • Multi-Game Support: Genshin Impact, Honkai: Star Rail, and Zenless Zone Zero
  • Strongly Typed Models: Clear and user-friendly C# models for all entities
  • Flexible Client Setup:
    • Direct Instantiation: await EnkaClient.CreateAsync(options)
    • Dependency Injection: services.AddEnkaNetClient(options => { ... })
  • HTTP Resiliency: Polly-powered retry with exponential backoff + jitter, circuit breaker, and 429 Retry After support
  • Multi-Provider Caching: Memory (default), SQLite, Redis, or custom IEnkaCache
  • Asset Preloading: Warm up game assets at startup for zero-latency first requests
  • Observability: OpenTelemetry ActivitySource + System.Diagnostics.Metrics hooks for traces and metrics

Supported Games

Game Status Method
Genshin Impact ✅ Ready UID
Honkai: Star Rail ✅ Ready UID
Zenless Zone Zero ✅ Ready UID

Miscellaneous

Feature Status Method
Fetch Basic Profile ✅ Ready Enka Username
Genshin Impact ✅ Ready Enka Username
Honkai: Star Rail ✅ Ready Enka Username
Zenless Zone Zero ✅ Ready Enka Username

Installation

dotnet add package EnkaDotNet

Usage & Examples

Enka.DotNet supports both direct instantiation and Dependency Injection.

Direct Instantiation

var options = new EnkaClientOptions
{
    EnableCaching = true,
    CacheDurationMinutes = 10,
    UserAgent = "MyApp/1.0"
};
await using IEnkaClient client = await EnkaClient.CreateAsync(options);

Dependency Injection (ASP.NET Core / Worker Service)

builder.Services.AddEnkaNetClient(options =>
{
    options.EnableCaching = true;
    options.CacheDurationMinutes = 10;

    // Warm up assets at startup (runs via IHostedService, never blocks DI thread)
    options.PreloadedLanguages = new List<Language> { Language.English, Language.Japanese };
});

For detailed runnable examples, see the Examples/ directory in the repository.

Caching

Cache Providers

Configure the cache provider via EnkaClientOptions.CacheProvider:

// In memory (default)
options.CacheProvider = CacheProvider.Memory;

// SQLite (persistent across restarts, no external dependency)
options.CacheProvider = CacheProvider.SQLite;
options.SQLiteCache = new SQLiteCacheOptions
{
    DatabasePath = "enka_cache.db",
    DefaultTtl = TimeSpan.FromMinutes(10)
};

// Redis (distributed, for multi instance apps)
options.CacheProvider = CacheProvider.Redis;
options.RedisCache = new RedisCacheOptions
{
    ConnectionString = "localhost:6379",
    KeyPrefix = "myapp:enka:"
};

Runtime Cache Control

// Force fresh data for one call
var profile = await client.GetGenshinPlayerInfoAsync(uid, bypassCache: true);

// Clear all cached entries
client.ClearCache();

// Get cache statistics
var (count, _) = client.GetCacheStats();

Language

All game API methods accept a Language enum for type safe language selection:

// Using Language enum (recommended)
var playerInfo = await client.GetZZZPlayerInfoAsync(uid, Language.Japanese);
var hsrInfo    = await client.GetHSRPlayerInfoAsync(uid, Language.TraditionalChinese);
var giInfo     = await client.GetGenshinPlayerInfoAsync(uid, Language.German);

// Using string (still supported)
var playerInfo = await client.GetZZZPlayerInfoAsync(uid, language: "ja");

Available languages:

Enum Value String Code
Language.English en
Language.Russian ru
Language.Vietnamese vi
Language.Thai th
Language.Portuguese pt
Language.Korean ko
Language.Japanese ja
Language.Indonesian id
Language.French fr
Language.Spanish es
Language.German de
Language.TraditionalChinese zh-tw
Language.SimplifiedChinese zh-cn
Language.Italian it
Language.Turkish tr

HTTP Resiliency

Resiliency is configured via EnkaClientOptions:

options.MaxRetries = 3;                         // Retry attempts (default: 1)
options.RetryDelayMs = 1000;                    // Base delay in ms (default: 1000)
options.UseExponentialBackoff = true;           // Exponential backoff with jitter (default: true)
options.MaxRetryDelayMs = 30000;                // Cap on retry delay (default: 30000)
options.CircuitBreakerFailureThreshold = 5;     // Failures before circuit opens (default: 5)
options.CircuitBreakerBreakDurationSeconds = 30; // Seconds circuit stays open (default: 30)

429 Too Many Requests is automatically retried using the Retry-After response header as the delay. A RateLimitException is only thrown after all retry attempts are exhausted.

Observability

The library exposes OpenTelemetry hooks with no additional dependencies. Wire up your own exporters:

// Distributed tracing
builder.Services.AddOpenTelemetry()
    .WithTracing(t => t.AddSource("EnkaDotNet").AddOtlpExporter());

// Metrics (counters + request duration histogram)
builder.Services.AddOpenTelemetry()
    .WithMetrics(m => m.AddMeter("EnkaDotNet").AddPrometheusExporter());

Exposed metrics:

Metric Description
enka.requests.total Total API requests made
enka.cache.hits Cache hit count
enka.cache.misses Cache miss count
enka.retries.total Total retry attempts
enka.request.duration (ms) Request duration histogram

Asset Preloading

Preloading warms up the in-memory asset cache at startup so the first real request has zero asset-load latency:

// Direct instantiation
await using var client = await EnkaClient.CreateAsync(new EnkaClientOptions
{
    PreloadedLanguages = new List<Language> { Language.English, Language.Japanese }
});

// DI (runs asynchronously via IHostedService)
builder.Services.AddEnkaNetClient(options =>
{
    options.PreloadedLanguages = new List<Language> { Language.English, Language.Japanese };
});

Asset Fallback (Offline / GitHub Unavailable)

Set AssetFallbackDirectory to make the library resilient to network outages. The first time an asset is downloaded successfully it is saved to disk. If a subsequent download fails (GitHub down, no internet), the saved copy is served instead.

options.AssetFallbackDirectory = "/path/to/your/enka_assets";

By default (null) nothing is ever written to disk.

Where do the files go?

The path is set by your application, the library just reads and writes to wherever you point it. The NuGet package folder (~/.nuget/packages/enkadotnet/) is read only and shared, files are never written there.

App type Recommended path Resolves to (example)
ASP.NET Core / Worker Service Path.Combine(builder.Environment.ContentRootPath, "enka_assets") /myapp/enka_assets/
Console app Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "EnkaDotNet", "assets") C:/Users/john/AppData/Local/EnkaDotNet/assets
Docker Mount a volume and set the path explicitly /data/enka_assets

Avoid using AppContext.BaseDirectory that resolves to the build output folder (bin/Release/net8.0/) which is wiped on each rebuild.

Full ASP.NET Core example:

builder.Services.AddEnkaNetClient(options =>
{
    // Writes to <project-root>/enka_assets/ which survives rebuilds
    options.AssetFallbackDirectory =
        Path.Combine(builder.Environment.ContentRootPath, "enka_assets");

    options.PreloadedLanguages = new List<Language> { Language.English, Language.Japanese };
});

Saved file layout:

enka_assets/
  genshin/ characters.json  text_map.json  namecards.json  ...
  hsr/     honker_characters.json  honker_weps.json  ...
  zzz/     avatars.json  weapons.json  property.json  ...

Requirements

  • .NET Standard 2.0 compatible framework (.NET Core 2.0+, .NET Framework 4.6.1+, .NET 5+)

Support

Having questions or issues? Join our Discord server: Alg's Dev Env

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Acknowledgments


Disclaimer

This project is not affiliated with or endorsed by HoYoverse (COGNOSPHERE PTE. LTD.) or Enka.Network. Genshin Impact, Honkai: Star Rail, and Zenless Zone Zero are trademarks of HoYoverse.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.1.6.7 98 4/18/2026
0.1.6.7 94 4/18/2026