Skip to content

Instantly share code, notes, and snippets.

@mlusiak
Last active December 30, 2015 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlusiak/7901990 to your computer and use it in GitHub Desktop.
Save mlusiak/7901990 to your computer and use it in GitHub Desktop.
Getting Json from bitstamp.net API and parsing it with Json Type Provider
let getHttp (url: string) =
let req = System.Net.WebRequest.Create(url)
let resp = req.GetResponse()
let stream = resp.GetResponseStream()
let reader = new StreamReader(stream)
let html = reader.ReadToEnd()
resp.Close()
html
type Bitstamp = JsonProvider<""" {"high": "844.00", "last": "714.33", "timestamp": "1386459953", "bid": "713.10", "volume": "81293.11654151", "low": "542.38", "ask": "713.88"} """>
let currentPrice() =
let tickerJson = getHttp "https://www.bitstamp.net/api/ticker/"
let ticker = Bitstamp.Parse(tickerJson)
(ticker.Timestamp, ticker.Last)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment