Skip to content

Instantly share code, notes, and snippets.

@julianeon
Created March 25, 2015 18:09
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 julianeon/d5d237a975cd671bed57 to your computer and use it in GitHub Desktop.
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).
#!/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