TheGamesDBApiWrapper 1.0.4

Install-Package TheGamesDBApiWrapper -Version 1.0.4
dotnet add package TheGamesDBApiWrapper --version 1.0.4
<PackageReference Include="TheGamesDBApiWrapper" Version="1.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TheGamesDBApiWrapper --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TheGamesDBApiWrapper, 1.0.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install TheGamesDBApiWrapper as a Cake Addin
#addin nuget:?package=TheGamesDBApiWrapper&version=1.0.4

// Install TheGamesDBApiWrapper as a Cake Tool
#tool nuget:?package=TheGamesDBApiWrapper&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

TheGamesDBApiWrapper

Wrapper Lib for handling requests to the TheGamesDB API. For API-Docs look here: https://api.thegamesdb.net/#/

Nuget Downloads

NOTE Not a official release - so no warranty for usage.

External Libraries This Library uses the following lib(s) fro archive its functionality:

Requirements

Install

Nuget:

Install-Package TheGamesDBApiWrapper 

Dotnet Cli

dotnet add package TheGamesDBApiWrapper

Usage

Add

Add to Services:

//Startup.cs

public IServiceProvider ConfigureServices(IServiceCollection services) {
    
    // Variant 1: Load Settings from IConfiguration for API Wrapper (See Readme.md -> Configure for more details):
    services.AddTheGamesDBApiWrapper();
    // Variant 2: Provide a type of TheGamesDBApiConfigModel to configure the api lib.
    services.AddTheGamesDBApiWrapper(new TheGamesDBApiConfigModel() {
        BaseUrl = "....", // Change Base Url for API Requests e.g. for proxies (Defaults to: https://api.thegamesdb.net/)
        Version = 1, //Indicate the Version to use of the API (Defaults to 1)
        ApiKey = "abc",  // The API Key to use (either the one lifetime private key or the public key received by the API Team of "TheGamesDB" see "Requirements",
        ForceVersion = false // Indicates if version is forces to use - see Configure Readme Section for more
    });
    
    // Variant 3: Provide value by value
     services.AddTheGamesDBApiWrapper("apikey",1, "https://api.thegamesdb.net/");
  
}

Configure

You can configure the API Lib by using the App Configuration. For Example in your appsettings.json:

{
  ...
  "TheGamesDB": {
     "BaseUrl": "https://api.thegamesdb.net/",
     "Version": 1,
     "ApiKey": "abcdefg",
     "ForceVersion": false
  }
  
  ...
}
Property Description Type Default
BaseUrl The Base Url for all API Requests String https://api.thegamesdb.net/
Version The API Version to use Double 1
ApiKey The API Key to use for requests String NULL
ForceVersion By default, The API Lib will try to get the highest possible minor version of an api endpoint (1.1,1.2, 1.3 etc) So if you select version 1 and Version 1.3 is declared for this endpoint the Lib will use 1.3 for requests. If you force the version it will ignore minor versions and use the configured version instead - even if its not available for this endpoint. So use this with caution Boolean FALSE

Use

To use it in code simple inject the API Class to your service or controller:

public class MyServiceClass { 
  private ITheGamesDBAPI api;
  
  public MyServiceClass(ITheGamesDBAPI api) {
    this.api = api;
  }

The Api Wrapper Lib is built in fluent pattern and based on the documentation of TheGamesDB api. So for loading all Platforms which is the api endpoint /Platforms you simple call:

var platforms = await this.api.Platform.All();

All parameters of all methods in the specific api class is documented in the "TheGamesDB" Api Docs

Helpers

Paginating

All paginated responses have two helper methods called NextPage and PreviousPage. So you can swap between pages by calling this async methods. For Example:

var gamesresponse = await this.api.Games.ByGameName("Counter");

// Info about current, next, prev page is stored in the sub oject "Pages"

// Check if we have a next page and switch to it

if (gamesresponse.Pages?.Next != null) {
    var nextResponse = await gamesresponse.NextPage();
    // Do something...
}

// Same for prev. page:
if (gamesresponse.Pages?.Previous != null) {
    var prevResponse = await gamesresponse.PreviousPage();
    // Do something...
}

Contribute

If you find any bug or want to add an feature. Simply create an Issue. And submit an pull request with your changes and link it the issue.

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.0.4 107 7/1/2021
1.0.3 89 5/19/2021
1.0.2 60 4/9/2021
1.0.1 73 4/8/2021
1.0.0 74 4/8/2021

* Fixed Game Update Call to allow all value types (objects, non object, string, int). The Game Update Response Model will have now an additional Property called "Values" of Type "GameUpdateValueModel" which has  3 Properties: Value, Values and Objects. One is set, the rest will be NULL. See: [GameUpdateValueModel](https://github.com/nfMalde/TheGamesDBApiWrapper/blob/main/src/Models/Responses/Games/GameUpdateValueModel.cs)