DiscourseApi 1.0.13
See the version list below for details.
dotnet add package DiscourseApi --version 1.0.13
NuGet\Install-Package DiscourseApi -Version 1.0.13
<PackageReference Include="DiscourseApi" Version="1.0.13" />
paket add DiscourseApi --version 1.0.13
#r "nuget: DiscourseApi, 1.0.13"
// Install DiscourseApi as a Cake Addin #addin nuget:?package=DiscourseApi&version=1.0.13 // Install DiscourseApi as a Cake Tool #tool nuget:?package=DiscourseApi&version=1.0.13
DiscourseApi
This is a C# wrapper to (the most important bits of) the Discourse API.
It is provided with a Visual Studio 2019 build solution for .NET Standard, so can be used with any version of .NET.
There is a test project (for net core only) which also demonstrates usage.
Setup before using the API
In order to use the Discourse API you need to obtain an ApiKey from the relevant Discourse server admin panel. You also need to supply an Api Username.
This information has to be provided in an object that implements the ISettings interface, which is then used to create a DiscourseApi instance. A Settings class which implements this interface is provided, to save you work. This provides a static Load method, reads the settings from LocalApplicationData/DiscourseApi/Settings.json. On a Windows 10 machine, LocalApplicationData is C:\Users\<USER>\AppData\Local
, on Linux it is ~user/.local/share
.
Testing
In order to run the Unit Tests provided, you must provide additional data in your ISettings object - see the Settings object in UnitTest1.cs.
Hooks for more complex uses
You do not have to use the provided Settings class, provided you have a class that implements ISettings.
License
This wrapper is licensed under creative commons share-alike, see license.txt.
Using the Api
The Unit Tests should give you sufficient examples on using the Api.
An Api instance is created by passing it an object that implements ISettings (a default class is provided which will read the settings from a json file). The Api instance is IDisposable, so should be Disposed when no longer needed (this is because it contains an HttpClient).
C# classes are provided for the objects you can send to or receive from the Discourse api. For instance the Group object represents groups. These main objects have methods which call the Discourse api - such as Group.Create to create a new group, Group.Get to get group details, etc.
Some Api calls return a list of items (such as Group.ListAll). These are returned as a subclass of ApiList<Group>. The Discourse api itself usually only returns the first few items in the list, and needs to be called again to return the next chunk of items. This is all done for you by ApiList - it has a method called All(Api) which will return an IEnumerable of the appropriate listed object. Enumerating the enumerable will return all the items in the first chunk, then call the Discourse api to get the next chunk, return them and so on. It hides all that work from the caller, while remaining as efficient as possible by only getting data when needed - for instance, using Linq calls like Any or First will stop getting data when the first item that matches the selection function is found.
Product | Versions 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- MimeMapping (>= 1.0.1.12)
- Newtonsoft.Json (>= 12.0.2)
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.29 | 2,190 | 11/16/2020 |
1.0.28 | 643 | 9/8/2020 |
1.0.27 | 556 | 7/14/2020 |
1.0.26 | 657 | 4/14/2020 |
1.0.25 | 486 | 4/7/2020 |
1.0.24 | 502 | 3/17/2020 |
1.0.23 | 559 | 2/21/2020 |
1.0.22 | 681 | 2/16/2020 |
1.0.21 | 491 | 2/11/2020 |
1.0.20 | 584 | 12/16/2019 |
1.0.19 | 507 | 12/9/2019 |
1.0.18 | 538 | 12/6/2019 |
1.0.17 | 575 | 12/4/2019 |
1.0.16 | 503 | 12/2/2019 |
1.0.15 | 532 | 11/28/2019 |
1.0.13 | 539 | 11/20/2019 |
1.0.12 | 535 | 11/18/2019 |
1.0.11 | 581 | 10/2/2019 |
1.0.10 | 546 | 9/5/2019 |
1.0.8 | 519 | 9/5/2019 |
1.0.6 | 531 | 8/30/2019 |
1.0.5 | 600 | 8/22/2019 |
1.0.2 | 587 | 8/15/2019 |
1.0.1 | 589 | 7/16/2019 |
1.0.0 | 562 | 7/11/2019 |
Add RemoveUsers to Group