Skip to content

snixtho/ManiaExchange.ApiClient

Repository files navigation

ManiaExchange API Client

General purpose API client for ManiaExchange. The library implements a client wrapper for the version of ManiaExchange's API (v2) as defined here.

Built with the HTTP API Wrapper Framework.

Installation

You can find the package on NuGet or install with the dotnet tool:

dotnet add package ManiaExchange.ApiClient

Usage

The library exposes classes for each of MX's websites:

Example basic usage

using ManiaExchange.ApiClient;

// instanitate the API class, pass a user agent to the constructor
var api = new TmxTmApi("My MX Client");

// call an api endpoint, in this case: /api/tags/gettags
var tags = await api.GetTagsAsync();

// the method returns a C# native object parsed from the response
foreach (var tag in tags)
{
    Console.WriteLine(tag.Name);
}

Caching

Since ManiaExchange encourage caching of GET methods, you can cache time by using the SetCacheTime method. This will cache all next GET requests for the specified time. Caching is disabled by default.

Cache can be disabled by either passing TimeSpan.Zero to SetCacheTime or use the shortcut DisableCache method.

Examples

You can find more examples in the Samples directory.

Documentation

Since all the methods have an almost direct 1:1 mapping to the original API as defined at api2.mania.exchange you can use this website as a reference. The methods are categorized into their respective classes. All the methods and objects are also commented with the same documentation on the MX API docs website for your convenience.

Issues

This project is not affiliated with ManiaExchange, so for issues related to the API itself, please refer to the ManiaExchange API documentation website or ManiaExchange's support channel.

For issues related to the client and library itself, feel free to open an issue in this repository.