TheGamesDBApiWrapper 1.0.2

Suggested Alternatives

TheGamesDBApiWrapper 2.0.0

Additional Details

Version 1.x is no longer maintained / supported. Please upgrade to  2.x whenever its possible.

There is a newer version of this package available.
See the version list below for details.
dotnet add package TheGamesDBApiWrapper --version 1.0.2
NuGet\Install-Package TheGamesDBApiWrapper -Version 1.0.2
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="TheGamesDBApiWrapper" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TheGamesDBApiWrapper --version 1.0.2
#r "nuget: TheGamesDBApiWrapper, 1.0.2"
#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.
// Install TheGamesDBApiWrapper as a Cake Addin
#addin nuget:?package=TheGamesDBApiWrapper&version=1.0.2

// Install TheGamesDBApiWrapper as a Cake Tool
#tool nuget:?package=TheGamesDBApiWrapper&version=1.0.2

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.

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. 
.NET Core netcoreapp3.1 is compatible. 
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
2.0.0 124 9/4/2023
1.3.1 467 4/12/2022
1.3.0 437 2/10/2022
1.2.0 442 2/7/2022
1.1.1 454 1/21/2022
1.1.0 429 1/21/2022
1.0.5 1,776 11/26/2021
1.0.4 357 7/1/2021
1.0.3 343 5/19/2021
1.0.2 342 4/9/2021
1.0.1 349 4/8/2021
1.0.0 363 4/8/2021

Added License and Package Info