class CryptoControl::QueryAPI

Public Class Methods

new(apiKey, proxyURL = nil) click to toggle source
# File lib/crypto-news-api.rb, line 9
def initialize(apiKey, proxyURL = nil)
  @apiKey = apiKey
  @proxyURL = proxyURL
  @sentiment = false
end

Public Instance Methods

enableSentiment() click to toggle source
# File lib/crypto-news-api.rb, line 35
def enableSentiment()
  @sentiment = true
end
fetch(url) click to toggle source
# File lib/crypto-news-api.rb, line 16
def fetch (url)
  host = @proxyURL ? @proxyURL : 'https://cryptocontrol.io/api/v1/public'
  sentiment = "sentiment=#{@sentiment}"
  url = URI.parse("#{host}#{url}#{url.include?("?") ? "&" : "?" }#{sentiment}")
  https = Net::HTTP.new(url.host, url.port)
  https.use_ssl = true

  headers = {
    'user-agent' => 'CryptoControl Ruby API v1.2.0',
    'content-type' =>'application/json',
    'x-api-key' => @apiKey
  }

  req = Net::HTTP::Get.new(url.to_s, initheader = headers)
  res = https.request(req)
  JSON.parse(res.body)
end
getCoinDetails(coin) click to toggle source
# File lib/crypto-news-api.rb, line 114
def getCoinDetails(coin)
  fetch "/details/coin/#{coin}"
end
getKeyDetails() click to toggle source
# File lib/crypto-news-api.rb, line 40
def getKeyDetails
  fetch '/'
end
getLatestFeedByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 100
def getLatestFeedByCoin(coin, lang = "en")
  fetch "/feed/coin/#{coin}?language=#{lang}&latest=true"
end
getLatestItemsByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 110
def getLatestItemsByCoin(coin, lang = "en")
  fetch "/all/coin/#{coin}?language=#{lang}&latest=true"
end
getLatestNews(lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 50
def getLatestNews(lang = "en")
  fetch "/news?latest=true&language=#{lang}"
end
getLatestNewsByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 65
def getLatestNewsByCoin(coin, lang = "en")
  fetch "/news/coin/#{coin}?language=#{lang}&latest=true"
end
getLatestRedditPostsByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 80
def getLatestRedditPostsByCoin(coin, lang = "en")
  fetch "/reddit/coin/#{coin}?language=#{lang}&latest=true"
end
getLatestTweetsByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 90
def getLatestTweetsByCoin(coin, lang = "en")
  fetch "/tweets/coin/#{coin}?language=#{lang}&latest=true"
end
getTopFeedByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 95
def getTopFeedByCoin(coin, lang = "en")
  fetch "/feed/coin/#{coin}?language=#{lang}"
end
getTopItemsByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 105
def getTopItemsByCoin(coin, lang = "en")
  fetch "/all/coin/#{coin}?language=#{lang}&latest=true"
end
getTopNews(lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 45
def getTopNews(lang = "en")
  fetch "/news?language=#{lang}"
end
getTopNewsByCategory(lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 55
def getTopNewsByCategory(lang = "en")
  fetch "/news/category?language=#{lang}"
end
getTopNewsByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 60
def getTopNewsByCoin(coin, lang = "en")
  fetch "/news/coin/#{coin}?language=#{lang}"
end
getTopNewsByCoinCategory(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 70
def getTopNewsByCoinCategory(coin, lang = "en")
  fetch "/news/coin/#{coin}/category?language=#{lang}"
end
getTopRedditPostsByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 75
def getTopRedditPostsByCoin(coin, lang = "en")
  fetch "/reddit/coin/#{coin}?language=#{lang}"
end
getTopTweetsByCoin(coin, lang = "en") click to toggle source
# File lib/crypto-news-api.rb, line 85
def getTopTweetsByCoin(coin, lang = "en")
  fetch "/tweets/coin/#{coin}?language=#{lang}"
end