Simple.API
1.9.1
dotnet add package Simple.API --version 1.9.1
NuGet\Install-Package Simple.API -Version 1.9.1
<PackageReference Include="Simple.API" Version="1.9.1" />
paket add Simple.API --version 1.9.1
#r "nuget: Simple.API, 1.9.1"
// Install Simple.API as a Cake Addin #addin nuget:?package=Simple.API&version=1.9.1 // Install Simple.API as a Cake Tool #tool nuget:?package=Simple.API&version=1.9.1
SimpleAPI
A simple C# REST API client implementation
Table of Contents
Compatibility
Huge compatibility, currently supports:
- .Net 8
- .Net 6
- .Net Core 3.1
- .Net Framework 4.5
- .Net Standard 1.1
- .NetCore 1.0+
- .Net Framework 4.5
- Mono 4.6+
- Xamarin.iOS 10.0+
- Xamarin.Android 7.0+
- UWP 8.0+
- Unity 2018.1+
Installing
Get from NuGet and start testing
Use
How to GET a resource at https://httpbin.org/anything/42
// Base address is used to reuse the client object
// but also do not have to repeat all the address
var client = new ClientInfo("https://httpbin.org/");
/* GET */
// no params
var get = await client.GetAsync<TestResponse>("anything");
// object builded param
var t = await client.GetAsync<TestResponse>("anything", new { id = "1234", value = 12.34 });
/* POST */
var post = await client.PostAsync<TestResponse>("anything", new { id = "1234", value = 12.34 });
/* And all others */
var putResponse = await client.PutAsync("anything", data);
var patchResponse = await client.PatchAsync("anything", data);
var deleteResponse = await client.DeleteAsync("anything");
Authentication:
// Using with JWT Token:
client.SetAuthorizationBearer(jwtToken);
// Using with BasicAuth
client.SetAuthorizationBasic(user, password);
// Using with other options (manually set)
client.SetAuthorization(headerKey, value);
// For other headers (like x-auth)
client.SetHeader("x-auth", xToken);
JWT parsing:
// Parse JWT
var jwt = JWT.Parse(token);
// Access commom fields
bool valid = jwt.Content.GetExp > DateTime.Now;
// Or parse your custom Model
var customJwt = JWT<YourModel>.Parse(token);
The response object contains the original data, status code, request and response headers
if(!putResponse.IsSuccessStatusCode)
Console.WriteLine("âšī¸");
if(patchResponse.StatusCode == HttpStatusCode.Forbidden)
Console.WriteLine("đ");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard1.1 is compatible. netstandard1.2 was computed. netstandard1.3 was computed. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 was computed. net451 was computed. net452 was computed. net46 was computed. 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 | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- Newtonsoft.Json (>= 13.0.3)
-
.NETStandard 1.1
- NETStandard.Library (>= 1.6.1)
- Newtonsoft.Json (>= 13.0.3)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.3)
-
net6.0
- Newtonsoft.Json (>= 13.0.3)
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on Simple.API:
Package | Downloads |
---|---|
Simple.HAApi
A simple Home-Assistant Rest API Client |
|
Sicoob.PIX
C# implementation for PIX with SICOOB |
|
Sicoob.Shared
Base library for Sicoob APIs for C# |
|
Sicoob.Conta
C# implementation for Bank Account with SICOOB |
|
Simple.BTC
C# REST Client for BTC Core API |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.9.1 | 130 | 10/8/2024 | |
1.9.0 | 97 | 10/8/2024 | |
1.8.0 | 420 | 5/6/2024 | |
1.7.2 | 413 | 3/26/2024 | |
1.7.1.3 | 597 | 1/4/2024 | |
1.7.1.2 | 800 | 12/8/2023 | |
1.7.1.1 | 202 | 10/28/2023 | |
1.7.0-rc | 166 | 1/30/2023 | |
1.6.3 | 2,082 | 1/30/2023 | |
1.6.2 | 1,747 | 1/24/2023 | |
1.6.1 | 341 | 1/20/2023 | |
1.6.0 | 327 | 1/19/2023 | |
1.5.5 | 334 | 1/5/2023 | |
1.5.4 | 440 | 8/4/2022 | |
1.5.3 | 435 | 7/14/2022 | |
1.5.2 | 973 | 7/9/2022 | |
1.5.1 | 1,191 | 6/3/2022 | |
1.5.0 | 978 | 4/18/2022 | |
1.4.5.1 | 417 | 4/13/2022 | |
1.4.5 | 471 | 4/9/2022 | |
1.4.4.3 | 463 | 2/23/2022 | |
1.4.4.2 | 581 | 2/23/2022 | |
1.4.4.1 | 471 | 2/23/2022 | |
1.4.4 | 436 | 2/18/2022 | |
1.4.3 | 409 | 2/4/2022 | |
1.4.0 | 440 | 1/13/2022 | |
1.3.2 | 337 | 5/12/2021 | |
1.3.1 | 309 | 5/12/2021 | |
1.2.0 | 346 | 5/12/2021 | |
1.1.0 | 346 | 5/3/2021 | |
1.0.0 | 395 | 5/2/2021 |
See examples and documentation on the GitHub page https://github.com/RafaelEstevamReis/SimpleAPI