Skip to content

Instantly share code, notes, and snippets.

@buddies2705
Created October 15, 2020 17:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buddies2705/4a60d6d8cc5c40fffa09bb5810934fd2 to your computer and use it in GitHub Desktop.
Save buddies2705/4a60d6d8cc5c40fffa09bb5810934fd2 to your computer and use it in GitHub Desktop.
Using GraphQL with Ruby
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse('https://graphql.bitquery.io/')
header = {'Content-Type': 'application/json'}
query = ' { bitcoin { blocks { count } } }'
puts query
# Create the HTTP objects
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = query.to_json
# Send the request
response = http.request(request)
puts "Body: #{response.body}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment