Delly.Fetching
2026.4.3
dotnet add package Delly.Fetching --version 2026.4.3
NuGet\Install-Package Delly.Fetching -Version 2026.4.3
<PackageReference Include="Delly.Fetching" Version="2026.4.3" />
<PackageVersion Include="Delly.Fetching" Version="2026.4.3" />
<PackageReference Include="Delly.Fetching" />
paket add Delly.Fetching --version 2026.4.3
#r "nuget: Delly.Fetching, 2026.4.3"
#:package Delly.Fetching@2026.4.3
#addin nuget:?package=Delly.Fetching&version=2026.4.3
#tool nuget:?package=Delly.Fetching&version=2026.4.3
Delly.Fetching
简体中文 | English
A modern, simple, and powerful HTTP client library for .NET.
✨ Features
- Simple API: Clean and intuitive interface for making HTTP requests
- Multiple HTTP Methods: Built-in support for GET, POST, PUT, DELETE
- Flexible Response Handling: Support for text and JSON deserialization
- Request/Response Interceptors: Hook into the request and response lifecycle
- Cross-platform: Supports .NET Standard 2.0 and .NET 5.0+
- Modern Design: Built with async/await patterns
📦 Installation
Install the package via NuGet:
dotnet add package Delly.Fetching
Or via the NuGet Package Manager:
Install-Package Delly.Fetching
🚀 Quick Start
Basic GET Request
using Delly.Fetching;
// Simple GET request
string html = await FetchUtils.GetAsync("https://api.example.com/data");
// Using builder pattern
string html = await FetchUtils.Create("https://api.example.com/data")
.Build()
.GetAsync();
GET Request with JSON Response
// Get and deserialize JSON response
var user = await FetchUtils.GetAsync<User>("https://api.example.com/user/1");
POST Request with JSON Data
using Delly.Fetching;
// POST request with JSON data
var loginData = new
{
userCode = "testuser",
password = "testpass"
};
var response = await FetchUtils.Create("https://api.example.com/login")
.AppendJsonData(loginData)
.PostAsync();
// POST request with JSON data and custom serialization options
var options = new JsonSerializerOptions {
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
var response = await FetchUtils.Create("https://api.example.com/users")
.AppendJsonData(newUser, options)
.PostAsync();
POST Request
using Delly.Fetching;
// Simple POST request
string response = await FetchUtils.PostAsync("https://api.example.com/users");
// POST request with JSON response
var newUser = await FetchUtils.PostAsync<User>("https://api.example.com/users");
Using the Builder Pattern
using Delly.Fetching;
// Create a client with custom configuration
var client = FetchUtils.Create("https://api.example.com/data")
.Request(builder => {
// Customize request
builder.SetMethod(HttpMethod.Get);
builder.OnBuilding(request => {
request.Headers.Add("Authorization", "Bearer your-token");
});
})
.Build();
// Send request
string response = await client.GetAsync();
PUT and DELETE Requests
// PUT request
string updated = await FetchUtils.PutAsync("https://api.example.com/users/1");
// DELETE request
string result = await FetchUtils.DeleteAsync("https://api.example.com/users/1");
// Using client
var client = FetchUtils.Create("https://api.example.com/users/1").Build();
await client.PutAsync();
await client.DeleteAsync();
🎯 Advanced Usage
JSON Request Body
Send JSON data easily with the AppendJsonData extension method:
using Delly.Fetching;
// Simple JSON POST request
var userData = new
{
name = "John Doe",
email = "john@example.com"
};
var response = await FetchUtils.Create("https://api.example.com/users")
.AppendJsonData(userData)
.PostAsync();
// JSON POST with custom serialization options
var options = new JsonSerializerOptions {
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true
};
var response = await FetchUtils.Create("https://api.example.com/users")
.AppendJsonData(userData, options)
.PostAsync();
// JSON POST with additional headers
var response = await FetchUtils.Create("https://api.example.com/users")
.Request(builder => {
builder.AppendJsonData(userData);
builder.OnBuilding(request => {
request.Headers.Add("Authorization", "Bearer token");
});
})
.PostAsync();
Request Interceptors
var client = FetchUtils.Create("https://api.example.com/data")
.Build();
// Intercept and modify request before sending
client.OnRequesting(request => {
request.Headers.Add("Custom-Header", "value");
return request;
});
string response = await client.GetAsync();
Response Interceptors
var client = FetchUtils.Create("https://api.example.com/data")
.Build();
// Intercept and modify response after receiving
client.OnResponsing(response => {
// Log response status
Console.WriteLine($"Status: {response.StatusCode}");
return response;
});
string response = await client.GetAsync();
Custom HttpClientHandler
var builder = FetchUtils.Create("https://api.example.com/data");
// Set custom HTTP client handler
builder.SetHttpHandler(new HttpClientHandler {
AutomaticDecompression = DecompressionMethods.GZip,
AllowAutoRedirect = true,
UseProxy = false
});
var client = builder.Build();
string response = await client.GetAsync();
JSON Deserialization with Custom Options
var options = new JsonSerializerOptions {
PropertyNameCaseInsensitive = true,
WriteIndented = true
};
var client = FetchUtils.Create("https://api.example.com/data")
.Build();
// Get JSON with custom options
var data = await client.GetAsync<MyData>(options);
📋 API Reference
Static Methods (FetchUtils)
| Method | Description |
|---|---|
Create(string url) |
Create a fetch builder with URL |
GetAsync(string url) |
GET request returning string |
GetAsync<T>(string url) |
GET request returning deserialized object |
PostAsync(string url) |
POST request returning string |
PostAsync<T>(string url) |
POST request returning deserialized object |
PutAsync(string url) |
PUT request returning string |
PutAsync<T>(string url) |
PUT request returning deserialized object |
DeleteAsync(string url) |
DELETE request returning string |
DeleteAsync<T>(string url) |
DELETE request returning deserialized object |
Extension Methods
IFetchBuilder Extensions
| Method | Description |
|---|---|
Request(Action<IFetchRequestBuilder>) |
Configure request builder |
AppendJsonData<T>(T data, JsonSerializerOptions) |
Add JSON data to request body |
IFetchRequestBuilder Extensions
| Method | Description |
|---|---|
AppendJsonData<T>(T data, JsonSerializerOptions) |
Add JSON data to request body |
Instance Methods (IFetchClient)
| Method | Description |
|---|---|
GetAsync() |
GET request returning string |
GetAsync<T>(JsonSerializerOptions) |
GET request returning deserialized object |
PostAsync() |
POST request returning string |
PostAsync<T>(JsonSerializerOptions) |
POST request returning deserialized object |
PutAsync() |
PUT request returning string |
PutAsync<T>(JsonSerializerOptions) |
PUT request returning deserialized object |
DeleteAsync() |
DELETE request returning string |
DeleteAsync<T>(JsonSerializerOptions) |
DELETE request returning deserialized object |
SendAsync(HttpMethod) |
Send request with specified method |
OnRequesting(Func) |
Register request interceptor |
OnResponsing(Func) |
Register response interceptor |
🏗️ Building from Source
# Clone the repository
git clone https://github.com/delly-net/Fetching.git
cd Fetching
# Restore dependencies
dotnet restore
# Build the solution
dotnet build
# Run tests
dotnet test
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Links
🙏 Acknowledgments
Thanks to all contributors who have helped make this project better.
Made with ❤️ by delly.net
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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
- System.Text.Json (>= 4.7.2)
-
net5.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Delly.Fetching:
| Package | Downloads |
|---|---|
|
Sup.OpenApi
Core component for Sup open API development kit |
GitHub repositories
This package is not used by any popular GitHub repositories.