Arquidev.Fetch 1.2.0

dotnet add package Arquidev.Fetch --version 1.2.0
                    
NuGet\Install-Package Arquidev.Fetch -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Arquidev.Fetch" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Arquidev.Fetch" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Arquidev.Fetch" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Arquidev.Fetch --version 1.2.0
                    
#r "nuget: Arquidev.Fetch, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Arquidev.Fetch@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Arquidev.Fetch&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Arquidev.Fetch&version=1.2.0
                    
Install as a Cake Tool

fetch

A minimal composable DSL for fetching JSON from HTTP (GET/POST).

NOTE: this IS NOT a general purpose HTTP client. If you need one, there are plenty to choose from. If you still want to use this and lack some features, use hack to access underlying HttpRequestMessage before sending.

It comes with builders allowing for sync (blocking) and async calls (both Task and Async variants):

  • fetch<'T> - Sync
  • fetchTask<'T> - Task async
  • fetchAsync<'T> - F# async
  • rq<'T> - just the request - use it to create parts that can be used in the fetch* builders

Examples

#r "paket: nuget Arquidev.Fetch ~> 1"
open Arquidev.Fetch
// POST with JSON body
let result = fetch<{|success: bool|}> {
    POST "https://api.example.com/users"
    Body {| name = "John"; email = "john@example.com" |}
    Authorization "Bearer token123"
}
if result.success then ...
// hack it
let data = fetch<Data> {
    GET "https://api.example.com/data"
    hack (fun req -> req.Headers.Add("X-Custom", "value"))
}

Look at tests.fsx for more.

Composition

Note: the order of composition is important if the same element is specified in both rq and fetch - the last declaration wins

// compose it

let common = rq {
    Authorization "Bearer token"
    UserAgent "MyApp/1.0"
}

fetch<Data> {
    GET "http://localhost"
    common
}

Console logging

*NOTE: for full headers and request/response content set env var: FETCH_DEBUG=1 or in code Fetch.debugEnabled true|false *

Fetch.enableLogs ()
//call(s) here
Fetch.disableLogs ()
Product Compatible and additional computed target framework versions.
.NET 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.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.2.0 111 7/31/2025
1.1.1 112 7/31/2025
1.1.0 118 7/31/2025
1.0.0 110 7/31/2025