<commit_before># SpeedrunComSharp

SpeedrunComSharp is a .NET wrapper Library for the [Speedrun.com
API](https://github.com/speedruncom/api). The current implementation of
SpeedrunComSharp implements all of the features available @ [`5ce7d20670ed89cc4b9781c0a745112eeef0cfe6`](https://github.com/speedruncom/api/tree/5ce7d20670ed89cc4b9781c0a745112eeef0cfe6).

## How to use

Download and compile the library and add it as a reference to your project. You then need to create an object of the `SpeedrunComClient` like so:

```C#
var client = new SpeedrunComClient();
```

The Client is separated into the following Sub-Clients, just like the Speedrun.com API:
* Categories
* Games
* Guests
* Levels
* Platforms
* Profile
* Records
* Regions
* Runs
* Users
* Variables

The only difference is the Records Sub-Client that allows you to use their legacy Records API that's available at http://www.speedrun.com/api_records.php.

The Sub-Clients implement all the API Calls for retrieving the Objects from the API. Once you obtained objects from those Clients, you can either use the References within the Objects to retrieve additional objects or you can use their IDs to retrieve them through the Clients. The Clients are somewhat more flexible though, as they can embed additional objects to decrease Network Usage.

## Example Usage

```C#
//Creating the Client
var client = new SpeedrunComClient();

//Searching for a game called "Wind Waker"
var game = client.Games.GetGames(name: "Wind Waker").First();

//Printing all the categories of the game
foreach (var category in Game.Categories)
{
  Console.WriteLine(category.Name);
}

//Searching for the category "Any%"
var anyPercent = game.Categories.First(category => category.Name == "Any%");

//Getting the leaderboard for the category
var leaderboard = anyPercent.Leaderboard;

//Finding the World Record of the category
var worldRecord = leaderboard.First();

//Getting the World Record Run
var worldRecordRun = worldRecord.Run;

//Printing the World Record's information
Console.WriteLine("The World Record is {0} by {1}", worldRecordRun.Times.Primary, worldRecordRun.Player.Name);

```<commit_msg>Explained the Optimizations done in SpeedrunComSharp<commit_after># SpeedrunComSharp

SpeedrunComSharp is a .NET wrapper Library for the [Speedrun.com
API](https://github.com/speedruncom/api). The current implementation of
SpeedrunComSharp implements all of the features available @ [`5ce7d20670ed89cc4b9781c0a745112eeef0cfe6`](https://github.com/speedruncom/api/tree/5ce7d20670ed89cc4b9781c0a745112eeef0cfe6).

## How to use

Download and compile the library and add it as a reference to your project. You then need to create an object of the `SpeedrunComClient` like so:

```C#
var client = new SpeedrunComClient();
```

The Client is separated into the following Sub-Clients, just like the Speedrun.com API:
* Categories
* Games
* Guests
* Levels
* Platforms
* Profile
* Records
* Regions
* Runs
* Users
* Variables

The only difference is the Records Sub-Client that allows you to use their legacy Records API that's available at http://www.speedrun.com/api_records.php.

## Example Usage

```C#
//Creating the Client
var client = new SpeedrunComClient();

//Searching for a game called "Wind Waker"
var game = client.Games.GetGames(name: "Wind Waker").First();

//Printing all the categories of the game
foreach (var category in Game.Categories)
{
  Console.WriteLine(category.Name);
}

//Searching for the category "Any%"
var anyPercent = game.Categories.First(category => category.Name == "Any%");

//Getting the leaderboard for the category
var leaderboard = anyPercent.Leaderboard;

//Finding the World Record of the category
var worldRecord = leaderboard.First();

//Getting the World Record Run
var worldRecordRun = worldRecord.Run;

//Printing the World Record's information
Console.WriteLine("The World Record is {0} by {1}", worldRecordRun.Times.Primary, worldRecordRun.Player.Name);

```

## Optimizations

The Sub-Clients implement all the API Calls for retrieving the Objects from the API. Once you obtained objects from those Clients, you can either use the References within the Objects to retrieve additional objects or you can use their IDs to retrieve them through the Clients. The Clients are somewhat more flexible though, as they can embed additional objects to decrease Network Usage.

The Library automatically minimizes Network Usage, so iterating over for example `category.Runs` multiple times only results in a single API Call. If you are iterating over an IEnumerable that results in a Paginated API Call, the API will only be called for those pages that you are iterating over. If two completely unrelated events result in the same API Call, the SpeedrunComSharp Library will notice that and return a cached result for the second API Call.
{'fraction_non_alphanumeric': 0.07647668393782384, 'fraction_numerical': 0.019896373056994817, 'mean_word_length': 4.958024691358025, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1605985', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1308, 'n_words': 584}