Skip to content

A client for the NexusMods API to proccess requests and resposes as described in the API documentaion, it handles the server responses and deseriliazes the content to .NET objects

License

Notifications You must be signed in to change notification settings

Proless/NexusModsNET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NexusModsNET

NuGet

A client for the NexusMods API to process requests and responses as described in the API documentation, it handles the server responses and deserializes the content to .NET objects

This is a .NET Standard 2.0 class library, it is compatible with every .NET Standard 2.0 supported platform as described here

Usage

The NexusModsClient is used by any Inquirer to process the requests and responses of the API, it also does the error-handling and deserialization to .NET objects. You can create a new Instance of the client by calling the NexusModsClient.Create method, which requires you to provide a valid API key and optionally your application name and version. Note that if you only provide a API key, then the name and version of this Library will be sent to the API with each request as per the API documentation.

var client = NexusModsClient.Create("your_private_api_key");

Inquirers

An Inquirer is the actual endpoint of the API, where you can call methods that corresponds the routes of the API

  • InfosInquirer
  • ColourSchemesInquirer
  • GamesInquirer
  • ModFilesInquirer
  • ModsInquirer
  • UserInquirer

Mainly you want to use the InfosInquirer, which combines all available endpoints of the API.

var client = NexusModsClient.Create("your_private_api_key");
var infosInquirer = new InfosInquirer(client);

Instantiating

You can use the provided NexusModsFactory to create Inquirers:

var infosInquirer = NexusModsFactory.New("your_private_api_key").CreateInfosInquirer();
var infosInquirerFactory = NexusModsFactory.New("your_private_api_key");
var userInquirer = infosInquirerFactory.CreateUserInquirer();

Limits management

The RateLimitsManagement property of an Inquirer helps you with reading the current limits of the API, you can also set your own custom daily and hourly limits and decide whether to throw an exception if they are both exceeded. Note that a LimitsExceededException will always be thrown if both API Limits are exceeded (100 Hourly, 2500 Daily). The RateLimitsManagement also has two events DailyLimitsExceeded and HourlyLimitsExceeded which will get invoked whenever a Limit is exceeded (both API and Custom) and recives a LimitType which is either API limit or Custom limit

/// <summary>
/// Indicates that a Daily limit has been exceeded.
/// </summary>
event EventHandler<LimitType> DailyLimitsExceeded;
/// <summary>
/// Indicates that a Hourly limit has been exceeded.
/// </summary>
event EventHandler<LimitType> HourlyLimitsExceeded;

Exceptions

  • NexusAPIException --> The base exception for all errors.
  • ForbiddenException
  • LimitsExceededException
  • UnauthorizedException

Any responses form the API with a status code that is not in the range 200 - 299 are treated as errors and an exception will be thrown based on the status code. All exceptions derive from the base exception class NexusAPIException

About

A client for the NexusMods API to proccess requests and resposes as described in the API documentaion, it handles the server responses and deseriliazes the content to .NET objects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages