Last active
December 30, 2015 23:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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