2 people like it.

Bitcoin current price data from blockchain.info

Using FSharp.Data

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
type BtcData = FSharp.Data.JsonProvider<"""{
  "USD":{"15m":1.1,"last":1.1,"buy":1.1,"sell":1.1,"symbol":"$"},
  "EUR":{"15m":1.1,"last":1.1,"buy":1.1,"sell":1.1,"symbol":"€"},
  "GBP":{"15m":1.1,"last":1.1,"buy":1.1,"sell":1.1,"symbol":"£"}
}""">

let prices = BtcData.Load("https://blockchain.info/ticker")
//prices.Eur.Buy  : val it : decimal = 923.52M (at 02/02/2017)
//prices.Gbp.Sell : val it : decimal = 794.61M (at 02/02/2017)
Multiple items
namespace FSharp

--------------------
namespace Microsoft.FSharp
Multiple items
namespace FSharp.Data

--------------------
namespace Microsoft.FSharp.Data
type JsonProvider

Full name: FSharp.Data.JsonProvider


<summary>Typed representation of a JSON document.</summary>
       <param name='Sample'>Location of a JSON sample file or a string containing a sample JSON document.</param>
       <param name='SampleIsList'>If true, sample should be a list of individual samples for the inference.</param>
       <param name='RootName'>The name to be used to the root type. Defaults to `Root`.</param>
       <param name='Culture'>The culture used for parsing numbers and dates. Defaults to the invariant culture.</param>
       <param name='Encoding'>The encoding used to read the sample. You can specify either the character set name or the codepage number. Defaults to UTF8 for files, and to ISO-8859-1 the for HTTP requests, unless `charset` is specified in the `Content-Type` response header.</param>
       <param name='ResolutionFolder'>A directory that is used when resolving relative file references (at design time and in hosted execution).</param>
       <param name='EmbeddedResource'>When specified, the type provider first attempts to load the sample from the specified resource
          (e.g. 'MyCompany.MyAssembly, resource_name.json'). This is useful when exposing types generated by the type provider.</param>
       <param name='InferTypesFromValues'>If true, turns on additional type inference from values.
          (e.g. type inference infers string values such as "123" as ints and values constrained to 0 and 1 as booleans.)</param>
val prices : FSharp.Data.JsonProvider<...>.Root

Full name: Script.prices
type BtcData = FSharp.Data.JsonProvider<...>

Full name: Script.BtcData
FSharp.Data.JsonProvider<...>.Load(uri: string) : FSharp.Data.JsonProvider<...>.Root


Loads JSON from the specified uri

FSharp.Data.JsonProvider<...>.Load(reader: System.IO.TextReader) : FSharp.Data.JsonProvider<...>.Root


Loads JSON from the specified reader

FSharp.Data.JsonProvider<...>.Load(stream: System.IO.Stream) : FSharp.Data.JsonProvider<...>.Root


Loads JSON from the specified stream
Raw view Test code New version

More information

Link:http://fssnip.net/7S0
Posted:7 years ago
Author:Tuomas Hietanen
Tags: bitcoin , btc