Git Product home page Git Product logo

blossomishymae / riotblossom Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 2.0 6.71 MB

An asynchronous, extensible, and magical Riot Games API wrapper library for C#. ☆*:.。.o(≧▽≦)o.。.:*☆

Home Page: https://blossomishymae.github.io/RiotBlossom/

License: MIT License

C# 99.40% TypeScript 0.55% CSS 0.05%
league-of-legends riot-games riot-games-api teamfight-tactics valorant csharp legends-of-runeterra

riotblossom's Introduction

RiotBlossom

NuGet Stable NuGet Downloads

An asynchronous, extensible, and magical Riot Games API wrapper library for C#. ☆*:.。.o(≧▽≦)o.。.:*☆

This library helps to make things totes' easier! Goodies include naive cache, rate limiter, and retry middleware plugins out of the box. Other services such as DataDragon and CommunityDragon are also supported! \(^▽^)/

This library is currently compatible with .NET 6 and higher.

Contributor Flowerlets


Made with contrib.rocks.

Table of Contents

Documentation, tutorials, and more!

Dedicated GitHub pages for RiotBlossom documentation can be found here! :3

Features

  • Asynchronous, immutable record, no-conversion API
    • API data comes as is from the source (Data transfer objects)
  • In-memory caching, spread rate limiting, and automatic retrying out of the box
  • Fluent client builder for advanced configuration
  • A highly configurable HTTP middleware system
    • Allows implementing your middleware (choosing a database to cache with)
    • Extensible subsystems (one for Riot API, one for the rest)
  • Reuseable data transfer objects, types, and exceptions
  • Common utilities (extensions, mappers, and converters)
  • Riot Games API support (yep!)
    • League of Legends
    • Teamfight Tactics
    • Legends of Runeterra
    • VALORANT
  • DataDragon support
  • CommunityDragon support
  • MerakiAnalytics support
  • Love (੭ु ›ω‹ )੭ु⁾⁾♡

Installation

Install via NuGet, BlossomiShymae.RiotBlossom. For package manager console:

Install-Package BlossomiShymae.RiotBlossom

Or the .NET CLI:

dotnet add package BlossomiShymae.RiotBlossom

Endpoints

Riot Api

  • ⭕ Account-v1 (no RSO)

League of Legends

  • ✅ Champion-Mastery-v4
  • ✅ Champion-v3
  • ✅ Clash-v1
  • ❌ League-Exp-v4 (will not support, experimental endpoint)
  • ✅ League-v4
  • ✅ Lol-Challenges-v1
  • ✅ Lol-Status-v4
  • ✅ Match-v5
  • ✅ Spectator-v4
  • ⭕ Summoner-v4 (no RSO)
  • ❌ Tournament-Stub-v4 (will not support, an endpoint that is associated with being unreliable)
  • ❌ Tournament-v4 (will not support)

Teamfight Tactics

  • ✅ Tft-League-v1
  • ✅ Tft-Match-v1
  • ✅ Tft-Status-v1
  • ⭕ Tft-Summoner-v1 (no RSO)

Legends of Runeterra

  • ⭕ Lor-Deck-v1 (no RSO, currently not supported)
  • ⭕ Lor-Inventory-v1 (no RSO, currently not supported)
  • ✅ Lor-Match-v1
  • ✅ Lor-Ranked-v1
  • ✅ Lor-Status-v1

VALORANT

  • ✅ Val-Content-v1
  • ✅ Val-Match-v1 ("Unsure if this works as I do not have access to this endpoint for testing ˚‧º·(˚ ˃̣̣̥⌓˂̣̣̥ )‧º·˚" - BlossomiShymae)
  • ✅ Val-Ranked-v1
  • ✅ Val-Status-v1

DataDragon

  • ✅ Champions (championFull.json)
  • ✅ Items (item.json)
  • ✅ Perks (runesReforged.json)

CommunityDragon

MerakiAnalytics

  • ✅ Champions (champions.json and individual files)
  • ✅ Items (items.json and individual files)

Dependent packages

Contributing

Create an issue or submit a pull request! ˖⁺‧₊˚ ♡ ˚₊‧⁺˖

Before submitting a pull request, be sure to include unit tests if applicable. Unit tests use common objects from the StubConfig file. Be sure to include your Riot API key under the RIOT_API_KEY system environment variable.

License

This library is under the MIT license.

Disclaimer

RiotBlossom isn't endorsed by Riot Games and doesn't reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games, and all associated properties are trademarks or registered trademarks of Riot Games, Inc.

Appendix

Star History

Star History Chart

Inspiration

TheDrone7. shieldbow, GitHub, https://github.com/TheDrone7/shieldbow

Samuel, Mingwei. Camille, GitHub, https://github.com/MingweiSamuel/Camille

Rua, Rob and Maldonis, Jason J. Orianna, GitHub, https://github.com/meraki-analytics/orianna

Resources

Ray and Riot Games. Rate Limiting, Hextechdocs, https://hextechdocs.dev/rate-limiting/

https://developer.riotgames.com/

https://discord.com/invite/riotgamesdevrel (Note: Searching in this Discord contains aggregated information not found elsewhere)

Conventions

https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions

https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/task-asynchronous-programming-model

riotblossom's People

Contributors

blossomishymae avatar markciliavincenti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

riotblossom's Issues

Request limit

Hey, I'm new to C# and to coding so be kind if my question is not pertinent.
I know that Riot Games request limit is 20 requests per second.
I'm getting sometimes a "TooManyRequestsException, and my program is only getting matchlist (very small program).
I'm having this issue while using the ListIdsByPuuidAsync while working with League of Legends API.
Capture d'écran 2023-07-29 222717
Capture d'écran 2023-07-29 222751
I think that the issue is caused by the Count parameter because when there are only 5 or 10 matches to retrieve, there is no problem, but when I ask up to 100 matches, the issue happens
I don't have yet the C# skills to see the source code on my own deeply so idk but this issue don't happen with other Api's packages (like in Python), so I just wanted to know if it's just a normal behavior, and the Riot request limit is normal.
Thanks a lot for your great work 🙌👍

Legends of Runeterra APIs

Legends of Runeterra

  • ➖ Lor-Deck-v1
  • ➖ Lor-Inventory-v1
  • ➖ Lor-Match-v1
  • ➖ Lor-Ranked-v1
  • ➖ Lor-Status-v1

Would be totes nice to have for the library. 💜

Teamfight Tactics APIs

Teamfight Tactics

  • ➖ Tft-League-v1
  • ➖ Tft-Match-v1
  • ➖ Tft-Status-v1
  • ➖ Tft-Summoner-v1

Would be nice to have this added to the library. 💚

VALORANT APIs

Valorant

  • ➖ Val-Content-v1
  • ➖ Val-Match-v1
  • ➖ Val-Ranked-v1
  • ➖ Val-Status-v1

Unsure of how to go about adding these without testing.

3448_EM_COSMIC_LUX_Inventory_100x100 blossoms

A `GetAsync` method for CommunityDragon interface

Just like GetAsync for the Riot interface but for CommunityDragon~

So something like this, wah!

byte[] challengeIcon = await client.CommunityDragon
    .GetAsync<byte[]>("/latest/game/assets/challenges/config/00_crystals/challengecrystal_platinum.png");

image

Improve spread rate limiting (SpreadShaper.cs)

I think the current spread limiting strategy for AlgorithmicLimiter can be improved upon. With how it works currently, it is set to be overly safe for the delay coefficient (3 * Math.Pow(progress, 2)). Unfortunately, a small percentage of requests (~0-5%) for a given limit is left unused. u.u

It works for now but it can probably be changed for the better. Setting the delay coefficient any lower will just trigger the WarningLimiterException (for smaller or larger rate limits I don't remember...), not what we wantsies.

See lines of code.

Add `ToString` method overrides for all objects in `Dto` namespace

All record objects under the Dto namespace currently use the compiler-generated ToString method. So this is what it currently looks like dayo~

image

The current ToString can print nested objects but not if the object is from the System.Collections namespace. There is also no indenting so it can be quite fugly. ( ´•̥ו̥` )

I think the ToString override should pretty much print all nested objects with some indentation. Maybe also provide a helper method the user can use to generate a pretty string? This would cover the challenge percentiles dictionary shown above (the last printed object)!

Add extension methods for `Platform`, `Region`, etc.

I have recently been rereading how Java enums work and inspecting the orianna library. Would be totes spectacular to increase the usability of enums and types like Platform, Region, etc. by making them easier and more powerful to use with the C# toolset.

Examples

Soon:

// => "na1"
Platform.NorthAmerica.GetId();
// => "en_US"
Platform.NorthAmerica.GetDefaultLocale();
// => "americas"
Platform.NorthAmerica.GetRegionId();

Now:

// => "na1"
PlatformMapper.GetId(Platform.NorthAmerica);
// no current equivalent

// => "americas"  this is totes ugly :c
RegionMapper.GetId(PlatformToRegionConverter.ToRegion(Platform.NorthAmerica));

hitori_happy

Expand on Quickstart, API Interfaces sections and add ASP.NET usage section

Quickstart

  • Add some data fetching walkthroughs for Teamfight Tactics and Legends of Runeterra (I can't really make one for VALORANT without access)

API Interfaces

  • Include the sub-interfaces for IRiotApi

Using for ASP.NET Core

  • Provide an example setup when using RiotBlossom with an ASP.NET Core project

I want to at least improve and expand on the current documentation before releasing 1.1.0! lol it is just a README why are you doing this, silly girl

flare-ok

Spread rate limiting (SpreadShaper class)

This library currently only supports rate-limiting requests via burst (see Middleware.BurstShaper). It would be nice to have a functional class that is able to spread out requests while respecting the parsed rate limits.

This is the Middleware.SpreadShaper class currently:

namespace BlossomiShymae.RiotBlossom.Middleware
{
    internal class SpreadShaper : IShaper
    {
        public Task UseRequestAsync(ExecuteInfo info, HttpRequestMessage req, Action next, Action<byte[]> hit)
        {
            throw new NotImplementedException();
        }

        public Task UseResponseAsync(ExecuteInfo info, HttpResponseMessage res, Action next)
        {
            throw new NotImplementedException();
        }
    }
}

My brain is on fire from trying to come up with a solution that isn't scuffed...

3145_EM_Soraka_Calm_Inventory_100x100 blossoms

Add file-based cache middleware plugin

Maybe store it in JSON files for better user-friendliness? It will be slower than in-memory caching anyways... (灬╹ω╹灬)

  • Store in JSON
  • Track expiration
  • Size limit
  • Folder location

Add low-level API interface for making requests

I think this feature would be awesome to have for making manual requests with the library that processes through the middleware plugins. So anyone can make requests to endpoints not yet supported (or will not support). So something like this, maybe:

// We are passing SummonerDto for strong-typing and JSON deserializing
SummonerDto summoner = 
    await client.Riot.GetAsync<SummonerDto>(Platform.NorthAmerica, "/lol/summoner/v4/summoners/by-name/uwuie time");

Or this:

SummonerDto summoner = 
    await client.Riot.GetAsync<SummonerDto>("na1", "/lol/summoner/v4/summoners/by-name/uwuie time");

Fluent builder:

SummonerDto summoner = await client.Riot.Request
    .WithRoute(Platform.NorthAmerica)
    .WithPath("/lol/summoner/v4/summoners/by-name/uwuie time")
    .GetAsync<SummonerDto>();

For JSON scalars:

int totalMasteryScore = await client.Riot.Request
    .WithRoute(Platform.NorthAmerica)
    .WithPath("/lol/champion-mastery/v4/scores/by-summoner/Ao5ffQ2dOV-99YKs_iB0g2EGzGD159jXIk2Z5MjvMafLwbQ")
    .GetAsync<int>();

ame_bee

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.