$ show BenFradet/RiotSharp
RiotSharp is a C# wrapper for the Riot Games API, providing access to League of Legends data including summoner information, match history, champion stats, leagues, and static game data. The library implements automatic rate limiting to comply with Riot's API constraints and includes caching for static data to minimize API calls. It features a layered architecture with separate projects for the core library, ASP.NET Core integration, and tests. The main entry point is the `RiotApi` class, which aggregates all endpoint interfaces via dependency injection. Key reusable components include a sophisticated rate limiter, a pluggable caching abstraction, a base class for static data endpoints, and custom JSON converters for enum serialization.
The LLM identified 4 files worth highlighting for reuse:
Implements a robust rate limiter that tracks multiple intervals (10-second and 10-minute windows) and handles HTTP 429 responses with retry-after delays. The class is thread-safe and can be extracted for use in any API client requiring rate limit compliance.
Defines a simple asynchronous caching interface with GetOrSetAsync method supporting sliding and absolute expiration. This abstraction enables pluggable cache implementations (in-memory, file, distributed) and is used throughout the library to reduce API calls for static data.
Base class for all static data endpoints (champions, items, runes, etc.) that handles URL construction, versioning, language parameters, caching, and HTTP requests. Subclasses specify the data model type, eliminating code duplication across similar endpoints.
Custom JsonConverter that serializes Platform enum to and from string representations as required by the Riot API. Demonstrates a reusable pattern for handling API-specific enum string mappings in JSON serialization/deserialization.