{"id":17761675,"url":"https://github.com/pathoschild/fluentnexus","last_synced_at":"2025-08-28T16:44:36.015Z","repository":{"id":46984487,"uuid":"183728860","full_name":"Pathoschild/FluentNexus","owner":"Pathoschild","description":"A modern async HTTP client for the Nexus Mods API.","archived":false,"fork":false,"pushed_at":"2022-12-08T14:51:03.000Z","size":93,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2024-10-14T11:36:49.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pathoschild.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-27T04:40:21.000Z","updated_at":"2024-09-29T22:58:21.000Z","dependencies_parsed_at":"2023-01-25T08:00:14.438Z","dependency_job_id":null,"html_url":"https://github.com/Pathoschild/FluentNexus","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pathoschild%2FFluentNexus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pathoschild%2FFluentNexus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pathoschild%2FFluentNexus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pathoschild%2FFluentNexus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pathoschild","download_url":"https://codeload.github.com/Pathoschild/FluentNexus/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221573569,"owners_count":16845859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-26T19:42:40.602Z","updated_at":"2024-10-26T19:42:41.234Z","avatar_url":"https://github.com/Pathoschild.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"**FluentNexus** is a modern async HTTP client for the Nexus Mods API. It gives you simple\nstrongly-typed methods to access all of the Nexus API endpoints, handling the gritty details like\ndeserialisation, content negotiation, URL encoding, and error-handling.\n\nDesigned with discoverability and extensibility as core principles, just autocomplete to see which\nmethods are available at each step.\n\n## Install\nInstall it [from NuGet](https://nuget.org/packages/Pathoschild.FluentNexus):\n\u003e Install-Package Pathoschild.FluentNexus\n\nThe client works on any modern platform (including Linux, Mac, and Windows):\n\n| platform                    | min version |\n| :-------------------------- | :---------- |\n| .NET Core                   | 1.0         |\n| .NET Framework              | 4.5         |\n| [.NET Standard][]           | 1.3         |\n| Mono                        | 4.6         |\n| Unity                       | 2018.1      |\n| Universal Windows Platform  | 10.0        |\n| Xamarin.Android             | 7.0         |\n| Xamarin.iOS                 | 10.0        |\n| Xamarin.Mac                 | 3.0         |\n\n## Use\n### Init a client\nCreate the client with your [personal API key](https://www.nexusmods.com/users/myaccount?tab=api)\n(or an [SSO key](https://github.com/Nexus-Mods/sso-integration-demo)), and an arbitrary app\nname/version which is just stored by Nexus for tracking:\n```c#\nvar nexus = new NexusClient(\"api key here\", \"My App Name\", \"1.0.0\");\n```\n\n### Basic examples\nNow just call its methods to interact with the Nexus API! \n\nFor example...\n\n* Start tracking a mod:\n  ```c#\n  await nexus.Users.TrackMod(\"stardewvalley\", 2400);\n  ```\n* Get a list of files for a mod:\n  ```c#\n  ModFileList files = await nexus.ModFiles.GetModFiles(\"stardewvalley\", 2400);\n  ```\n\n* Get download links for a mod file:\n   ```c#\n   ModFileDownloadLink[] downloadLinks = await nexus.ModFiles.GetDownloadLinks(\"stardewvalley\", 2400, 9622);\n   ```\n\n* Get a content preview for a mod file if it's an archive (e.g. `.zip`):\n  ```c#\n  ModFile file = await nexus.ModFiles.GetModFiles(\"stardewvalley\", 2400, 9622);\n  ContentPreview preview = await nexus.ModFiles.GetContentPreview(file.ContentPreviewLink);\n  ```\n\n* Which mods are being tracked by the user?\n  ```c#\n  UserTrackedMod[] mods = await nexus.Users.GetTrackedMods();\n  ```\n\nSee the [Nexus API docs](https://app.swaggerhub.com/apis-docs/NexusMods/nexus-mods_public_api_params_in_form_data/1.0)\nfor a list of endpoints and fields supported by this client.\n\n### Error-handling\nThe Nexus API returns errors in this format:\n```js\n{\n  \"code\": 403,\n  \"message\": \"You don't have permission to get download links from the API without visting nexusmods.com - this is for premium users only.\"\n}\n```\n\nThe client will throw an `ApiException` when that happens, which contains the HTTP status code,\nNexus error message, and response:\n```c#\ntry\n{\n   ModFileDownloadLink[] links = await nexus.ModFiles.GetDownloadLinks(\"stardewvalley\", 2400, 9622);\n}\ncatch (ApiException ex)\n{\n   if (ex.Status == HttpStatusCode.Forbidden \u0026\u0026 ex.Message.Contains(\"this is for premium users only\"))\n      // user needs a premium account\n}\n```\n\n## Advanced\n### Rate limits\nThe Nexus API sets some rate limits (see [API docs](https://app.swaggerhub.com/apis-docs/NexusMods/nexus-mods_public_api_params_in_form_data/1.0)),\nand will return HTTP 429 if you exceed them.\n\nYou can check your rate limit usage anytime. Since this is cached on each response, this will only\nping the Nexus API if you haven't sent a request recently. (Even if it does ping the API, this\nwon't be counted against your limits.) To check the rate limit values:\n\n```c#\nIRateLimitManager limits = await nexus.GetRateLimits();\nConsole.WriteLine($\"Daily usage: {limits.DailyRemaining}/{limits.DailyLimit} requests left, will reset at {limits.DailyReset}.\");\nConsole.WriteLine($\"Hourly usage: {limits.HourlyRemaining}/{limits.HourlyLimit} requests left, will reset at {limits.HourlyReset}.\");\n```\n\nThe client can also help you automate rate limit handling. For example, let's say you want\nto pause the script when you exceed the rate limits but resume when they renew:\n```c#\nIRateLimitManager rateLimits = await nexus.GetRateLimits();\nif (rateLimits.IsBlocked())\n{\n   TimeSpan renewDelay = rateLimits.GetTimeUntilRenewal();\n   Console.WriteLine($\"Exceeded rate limits, will resume at {DateTime.Now + renewDelay} local time.\");\n   Thread.Sleep(renewDelay);\n}\n```\n\n### Underlying HTTP client\nIf needed, you can use the underlying fluent HTTP client directly (e.g. for an unsupported endpoint):\n\n```c#\nMod mod = await nexus.HttpClient\n   .GetAsync($\"v1/games/{domainName}/mods/{modID}.json\")\n   .As\u003cMod\u003e();\n```\n\nSee [FluentHttpClient](https://github.com/Pathoschild/FluentHttpClient/) for documentation.\n\n### Synchronous use\nThe client is built around the `async` and `await` keywords, but you can use the client\nsynchronously. That's not recommended — it complicates error-handling (e.g. errors get wrapped\ninto [AggregateException][]), and it's very easy to cause thread deadlocks when you do this (see\n_[Parallel Programming with .NET: Await, and UI, and deadlocks! Oh my!][]_ and\n_[Don't Block on Async Code][])._\n\nIf you really need to use it synchronously, you can just call the `Result` property:\n```c#\nUserTrackedMod[] mods = nexus.Users.GetTrackedMods().Result;\n```\n\nOr if you don't need the response:\n\n```c#\nnexus.Users.TrackMod(\"stardewvalley\", 2400).Wait();\n```\n\n[.NET Standard]: https://docs.microsoft.com/en-us/dotnet/articles/standard/library\n[Parallel Programming with .NET: Await, and UI, and deadlocks! Oh my!]: https://blogs.msdn.microsoft.com/pfxteam/2011/01/13/await-and-ui-and-deadlocks-oh-my/\n[Don't Block on Async Code]: https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html\n[media type formatters]: https://www.nuget.org/packages?q=MediaTypeFormatter\n\n[AggregateException]: https://docs.microsoft.com/en-us/dotnet/api/system.aggregateexception\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathoschild%2Ffluentnexus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpathoschild%2Ffluentnexus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpathoschild%2Ffluentnexus/lists"}