EnkaDotNet 1.5.0.3

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

Features

  • Comprehensive Data Retrieval:
    • Fetch detailed character builds, player profiles, and stats for Genshin Impact, Honkai: Star Rail, and Zenless Zone Zero
  • Multi-Game Support: Easily switch between supported games.
  • Strongly Typed Models: Clear and user-friendly C# models for all entities
  • Flexible Client Setup:
    • Direct Instantiation: Use EnkaClient.CreateAsync() for quick setup
    • Dependency Injection: Integrate with .NET DI using AddEnkaNetClient()
  • Asset Management: Automatically fetches and caches game assets
  • Configurable Caching: Control cache duration, bypass, and clearing
  • Customizable Options: Adjust language, user agent, and API behavior

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 ❌ Not Ready Enka Username
Honkai: Star Rail ❌ Not Ready Enka Username
Zenless Zone Zero ❌ Not Ready Enka Username

Installation

Install EnkaDotNet via NuGet package manager:

Install-Package EnkaDotNet

Or via the .NET CLI:

dotnet add package EnkaDotNet

Usage & Examples

Enka.DotNet supports both direct instantiation (Non DI) for simpler applications and Dependency Injection (DI) for more complex setups like ASP.NET Core or Worker Services

Key Concepts:

  • EnkaClientOptions: Use this class to configure caching behavior and other settings.
  • Direct Instantiation Usage: Instantiate the client using the static factory method await EnkaClient.CreateAsync(options). This method handles asynchronous initialization of game assets.
  • Dependency Injection Usage: Register the client in your service collection using the services.AddEnkaNetClient(options => { ... }); extension method. Then, inject IEnkaClient into your services.

Detailed Code Examples

For detailed and runnable code examples demonstrating how to use Enka.DotNet for Genshin Impact, Honkai: Star Rail, and Zenless Zone Zero, please refer to the Examples/ directory within this repository.

The Examples/ folder contains separate projects for each game, showcasing:

  • Non DI (Direct Instantiation): Basic console applications showing how to set up and use the client directly.
  • DI (Dependency Injection): Examples using the .NET Generic Host to demonstrate DI setup and usage.

These examples cover fetching player profiles, character/agent details, equipment, stats, and more.

Controlling the Cache

Enka.DotNet provides several ways to control caching behavior for API responses.

1. Configuration via EnkaClientOptions

When creating an EnkaClient instance (either directly or via DI configuration), you can set the following options:

  • EnableCaching: A boolean (default true) to enable or disable caching entirely. If set to false, no responses will be cached, and every request will hit the Enka.Network API.
  • CacheDurationMinutes: An integer (default 5) specifying how long responses should be cached in minutes.

Example (Direct Instantiation):

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

Example (Dependency Injection in Program.cs):

builder.Services.AddEnkaNetClient(options =>
{
    options.EnableCaching = false; // Disable caching
    // options.CacheDurationMinutes will be ignored if EnableCaching is false
});

2. Runtime Cache Control via IEnkaClient

Bypassing Cache for Specific Requests

All data fetching methods on IEnkaClient (e.g., GetUserProfileAsync, GetHSRPlayerInfoAsync, GetZZZAgentsAsync) accept an optional bypassCache boolean parameter. Setting this to true for a specific call will force the client to fetch fresh data from the API, ignoring any existing cached response for that particular UID.

Example:

// Assuming client is an initialized IEnkaClient instance
int uid = 8000000;

// This call will use the cache if available and not expired
var (playerInfoCached, charactersCached) = await client.GetUserProfileAsync(uid, language: "en");

// This call will always fetch fresh data from the API
var (playerInfoFresh, charactersFresh) = await client.GetUserProfileAsync(uid, language: "en", bypassCache: true);
Clearing the Entire Cache

You can programmatically clear all cached responses held by an EnkaClient instance.

Example:

// Assuming client is an initialized IEnkaClient instance
client.ClearCache();
Console.WriteLine("All Enka.DotNet cache entries have been cleared.");
Getting Cache Statistics

You can retrieve statistics about the current state of the cache.

Example:

// Assuming client is an initialized IEnkaClient instance
var (currentEntryCount, expiredCountInfo) = client.GetCacheStats();
Console.WriteLine($"Current items in cache: {currentEntryCount}");
// Note: ExpiredCountNotAvailable indicates if the detailed count of expired items (before they arecompacted) is available.

Requirements

  • .NET Standard 2.0 compatible framework (e.g., .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 was computed.  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.5.0.3 21 7/19/2025
1.5.0.2 58 7/18/2025
1.5.0.1 103 7/13/2025
1.5.0 278 6/13/2025
1.4.9 285 6/12/2025
1.4.8.1 283 6/11/2025
1.4.8 195 6/8/2025
1.4.7 146 5/21/2025
1.4.6 232 5/12/2025
1.4.4.3 218 5/12/2025
1.4.3 130 5/11/2025
1.4.2 70 5/10/2025
1.4.1 76 5/9/2025
1.4.0 92 5/9/2025
1.3.4 147 5/6/2025
1.3.3.1 104 5/4/2025
1.3.3 112 5/4/2025
1.3.2 164 4/27/2025
1.3.1 107 4/25/2025
1.3.0 130 4/25/2025
1.2.0 162 4/24/2025
1.1.0.1 186 4/8/2025
1.1.0 141 4/8/2025
1.0.5 162 4/7/2025
1.0.4 159 4/6/2025
1.0.3.1 180 4/5/2025 1.0.3.1 is deprecated because it is no longer maintained.
1.0.3 176 4/5/2025 1.0.3 is deprecated because it is no longer maintained.
1.0.2 170 4/5/2025 1.0.2 is deprecated because it is no longer maintained.
1.0.1 93 4/5/2025 1.0.1 is deprecated because it has critical bugs.
1.0.0 93 4/5/2025 1.0.0 is deprecated because it has critical bugs.