Created
March 25, 2015 18:09
-
-
Save julianeon/d5d237a975cd671bed57 to your computer and use it in GitHub Desktop.
Get the current price in USD from SnapSwap (essentially, how many dollars it costs to buy 1 XRP).
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
#!/usr/bin/env ruby | |
require 'json' | |
require 'yaml' | |
ripple=YAML.load_file("ripple.yml") | |
server=ripple["server"]["api"] | |
snapswap=ripple["address"]["snapswap"] | |
bitstamp=ripple["address"]["bitstamp"] | |
info="/v1/accounts/#{snapswap}/payments/paths/#{snapswap}/1.0+XRP" | |
endpoint="#{server}#{info}" | |
cmd_curl=`curl -H "Content-Type: application/json" "#{endpoint}"` | |
output=JSON.parse(cmd_curl) | |
pays= output["payments"] | |
pays.each do |pay| | |
source= pay["source_account"] | |
pay_this= pay["source_amount"] | |
currency= pay_this["currency"] | |
amount= pay_this["value"] | |
if currency=="USD" | |
puts amount | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment