The Endpoint class in C# is a versatile HTTP client wrapper for making RESTful API calls. It supports various HTTP methods like GET POST PUT DELETE and PATCH and allows for header cookie and query parameter manipulation. It also provides basic and bearer token authentication.
Here're some of the project's best features:
Installation via command line using dotnet CLI.
dotnet add package FiveAnts.Endpointpublic class Todo
{
[JsonProperty("userId")]
public int UserId;
[JsonProperty("id")]
public int Id;
[JsonProperty("title")]
public string? Title;
[JsonProperty("completed")]
public bool Completed;
}
public static async Task<Todo> GetTodo()
{
var endpoint = new Endpoint<Todo>("https://jsonplaceholder.typicode.com");
//https://jsonplaceholder.typicode.com/todos/1
return await endpoint
.AppendPathSegments("todos", "1")
.GetAsync();
} public class Comments
{
[JsonProperty("postId")]
public int PostId;
[JsonProperty("id")]
public int Id;
[JsonProperty("name")]
public string? Name;
[JsonProperty("email")]
public string? Email;
[JsonProperty("body")]
public string? Body;
}
public static async Task<List<Comments>> GetComment()
{
var endpoint = new Endpoint<List<Comments>>("https://jsonplaceholder.typicode.com");
//https://jsonplaceholder.typicode.com/comments?postId=1
return await endpoint
.AppendPathSegment("comments")
.SetQueryParam("postId", 1)
.GetAsync();
}Technologies used in the project:
- .NET 8.0
- Newtonsot.Json
This project is licensed under the MIT License