Twileloop.JetAPI
1.1.0
Prefix Reserved
See the version list below for details.
dotnet add package Twileloop.JetAPI --version 1.1.0
NuGet\Install-Package Twileloop.JetAPI -Version 1.1.0
<PackageReference Include="Twileloop.JetAPI" Version="1.1.0" />
paket add Twileloop.JetAPI --version 1.1.0
#r "nuget: Twileloop.JetAPI, 1.1.0"
// Install Twileloop.JetAPI as a Cake Addin #addin nuget:?package=Twileloop.JetAPI&version=1.1.0 // Install Twileloop.JetAPI as a Cake Tool #tool nuget:?package=Twileloop.JetAPI&version=1.1.0
<br /> <div align="center"> <a href="https://github.com/sangeethnandakumar/Jet API"> <img src="https://github.com/sangeethnandakumar/Twileloop.JetAPI/raw/master/Twileloop.JetAPI/logo.png" alt="Logo" width="80" height="80"> </a>
<h2 align="center"> Jet API </h2> <h4 align="center"> Free | Open-Source | Fast </h4>
<p align="center"> <b> An easy to use conveinent fluent API requester for all your personal or commercial .NET apps </b> <br /> <a href="https://twileloop.epub.readthedocs.io"><strong>Explore the docs ยป</strong></a> <br /> <br /> <a href="https://github.com/sangeethnandakumar/Twileloop.EPub/issues">Report A Bug</a> ยท <a href="https://github.com/sangeethnandakumar/Twileloop.EPub/issues">Request A Feature</a> </p>
</div>
SonarCloud
- Continues security & maintanance scans on every bug fixes and features
- SonarCloud: Click Here For SonarCloud Report.
Fully Free
- MIT Licensed
- Fully free for personal/commercial projects without needing any commertial licenses or messes.
Feeling happy? A small coffee would be a great way to support my work. Thank you for considering it!
<div align="center">
<h2 align="center"> DOCUMENTATION </h2> <h4 align="center"> A fully free open source cross platform fluent APIClient for your .NET application </h4>
</div>
Simple GET
var response = await new JetRequest<dynamic>()
.ExecuteAsync("https://jsonplaceholder.typicode.com/posts/1");
GET ๐ With Query Params
var response = await new JetRequest<dynamic>()
.WithQueries(
new Param("postId", 2),
new Param("date", "1996-10-28")
)
.ExecuteAsync("https://jsonplaceholder.typicode.com/comments");```
GET ๐ With Headers
var response = await new JetRequest<dynamic>()
.WithQueries(
new Param("postId", 3)
)
.WithHeaders(
new Param("x-request-by", "name"),
new Param("x-limit", 150)
)
.ExecuteAsync("https://jsonplaceholder.typicode.com/comments"); .ExecuteAsync("https://jsonplaceholder.typicode.com/comments");```
POST ๐ With JSON String
var jsonString = @"{""title"":""Foo"",""bar"":""Bar"",""userid"":1}";
var response = await new JetRequest<dynamic>()
.Post()
.WithBody(
new RawBody(ContentType.Json, jsonString)
)
.ExecuteAsync("https://jsonplaceholder.typicode.com/posts");
PUT ๐ With Object As JSON
var instance = new {
Title = "Foo",
Bar = "Bar",
UserId = 1
};
var response = await new JetRequest<MyResponseModel>()
.Put()
.WithBody(
new RawBody(ContentType.Json, instance)
)
.ExecuteAsync("https://jsonplaceholder.typicode.com/posts");
GET ๐ With Basic-Authentication
var response = await new JetRequest<MyResponseModel>()
.Get()
.WithAuthentication(new BasicAuthentication {
Username = "username",
Password = "password"
})
.ExecuteAsync("https://jsonplaceholder.typicode.com/posts/5");
GET ๐ With JWT Bearer-Authentication
var response = await new JetRequest<MyResponseModel>()
.Get()
.WithAuthentication(new BearerToken("<BEARER_TOKEN>"))
.ExecuteAsync("https://jsonplaceholder.typicode.com/posts/5");
GET ๐ With API_KEY Authentication
var response = await new JetRequest<MyResponseModel>()
.Get()
.WithAuthentication(new ApiKey("Api-Key", "<API_KEY>"))
.ExecuteAsync("https://jsonplaceholder.typicode.com/posts/5");
PATCH ๐ And Handle Exceptions Yourself
var response = await new JetRequest<MyResponseModel>()
.Patch()
.HandleExceptions(
ex => Console.WriteLine($"An exception occured. Message: {ex.Message}");
)
.ExecuteAsync("htt://jsonplaceholder.typicode.com/posts/5");
GET ๐ With Success/Failure Captures
var response = await new JetRequest<MyResponseModel>()
.Get()
.WithCaptures(
successResponse => Console.WriteLine("Success");,
failureResponse => Console.WriteLine("Failure");
)
.ExecuteAsync("https://jsonplaceholder.typicode.com/posts/5");
PUT ๐ With Custom Captures Based On HTTP StatusCode
var response = await new JetRequest<MyResponseModel>()
.Put()
.WithCaptures(
(HttpStatusCode.OK, () => Console.WriteLine("Ok")),
(HttpStatusCode.NotFound, () => Console.WriteLine("Not Found")),
(HttpStatusCode.Unauthorized, () => Console.WriteLine("UnAuthorized")),
(HttpStatusCode.Forbidden, () => Console.WriteLine("Forbidden"))
)
.ExecuteAsync("https://jsonplaceholder.typicode.com/fake");
GET ๐ As JSON/XML/HTML or TEXT
var response = await new JetRequest<MyResponseModel>()
.Get()
.FetchAs(ContentType.XML)
.ExecuteAsync("https://samplexml.com/auth/demoxml.xml");
GET ๐ And Pass Request Cookies
var response = await new JetRequest<MyResponseModel>()
.WithCookies(
new Param("Cookie1", "<CookieValue1>"),
new Param("Cookie2", "<CookieValue2>")
)
.FetchAs(ContentType.HTML)
.ExecuteAsync("https://google.com");
Listen To Events With Interceptors
Create your own intercepter by inheriting from Interceptor base class
public class CustomInterceptor : Interceptor {
public override void OnInit() {
Console.WriteLine("Started...");
base.OnInit();
}
public override void OnRequesting(Request request) {
Console.WriteLine("Let's modify request from interceptor");
request.HttpClient.DefaultRequestHeaders.Add("Accept", "application/json");
Console.WriteLine("Enough. Now start requesting...");
base.OnRequesting(request);
}
public override void OnResponseReceived() {
Console.WriteLine("Got response...");
base.OnResponseReceived();
}
}
Do your stuff above. Alter anything before request goes or log result after response came etc.. Now let's attach this interceptor to JetAPI
var interceptor = new CustomInterceptor();
var response = await new JetRequest<dynamic>()
.Post()
.WithAuthentication(new BearerToken("<BEARER_TOKEN>"))
.WithInterceptor(interceptor)
.ExecuteAsync("https://jsonplaceholder.typicode.com/posts/5");
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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | 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.1
- System.Text.Json (>= 7.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.