Convert bitcoin value based on exchange rate from JSON API I’m learning F# and trying to find a more ‘functional’ way to code a simple program that retrieves the price of BTC and calculates the EUR value of an amount of Bitcoin.

open System
open System.Net
open Newtonsoft.Json.Linq

let myBTC = 0.1234567
let client = new WebClient()
client.UseDefaultCredentials = true
let priceInfo = client.DownloadString("https://blockchain.info/ticker")
let jPrice = JObject.Parse priceInfo
let eurPrice = float (jPrice.["EUR"].["buy"] :?&gt; JValue)
let calcWorth = myBTC * eurPrice
printfn "%s" calcWorth.ToString("N")
My take is that there is no harm in adding a few named functions. Also it is probably better to ignore the result of setting a standard .net property.

open System
open System.Net
open Newtonsoft.Json.Linq

let downloadPriceInfo () =
    let client = new WebClient()
    client.DownloadString("https://blockchain.info/ticker")

let getPriceOfEuro (price: JObject) = float (price.["EUR"].["buy"] :?&gt; JValue)

let euroToBtc euro = 0.1234567 * euro

let btcOfEuro = 
    downloadPriceInfo () 
    |&gt; JObject.Parse
    |&gt; getPriceOfEuro 
    |&gt; euroToBtc

printfn "%s" (btcOfEuro.ToString("N"))