class HypixelAPI

Base object for the api. Only create one for the entire build as it keeps track of your request limits. All methods are avaible at https://github.com/HypixelDev/PublicAPI/tree/master/Documentation/methods, use arguments are parms.

Public Class Methods

new(api_key) click to toggle source

Creates a new object with your API key. If requests are failing for you, remember to check your key.

# File lib/hypixel-ruby.rb, line 24
def initialize(api_key)
  @key = api_key
end

Public Instance Methods

boosters(args={}) click to toggle source

Fetches boosters and their active times.

# File lib/hypixel-ruby.rb, line 48
def boosters(args={})
  fetch(url(:"boosters", args))
end
fetch(url) click to toggle source

Parses url to Rubyfiy the request, internal so you won't need to use it for much.

# File lib/hypixel-ruby.rb, line 11
def fetch(url)
  if @min != Time.now.min
    @min = Time.now.min
    @requests = 0
  end
  if @requests < 120
    @requests += 1
    source = (open URI(url)).read
    return JSON.parse(source, :symbolize_names => true)
  end
end
findguild(args={}) click to toggle source

Finds a guild by name or player.

# File lib/hypixel-ruby.rb, line 53
def findguild(args={})
  fetch(url(:"findguild", args))
end
friends(args={}) click to toggle source

Refer to PublicAPI docs on this one.

# File lib/hypixel-ruby.rb, line 58
def friends(args={})
  fetch(url(:"friends", args))
end
guild(args={}) click to toggle source

Fetches guild data by id.

# File lib/hypixel-ruby.rb, line 63
def guild(args={})
  fetch(url(:"guild", args))
end
key(args={}) click to toggle source

Fetches info about current status of API key.

# File lib/hypixel-ruby.rb, line 68
def key(args={})
  fetch(url(:"key", args))
end
leaderboards(args={}) click to toggle source

Gets top players in each game.

# File lib/hypixel-ruby.rb, line 73
def leaderboards(args={})
  fetch(url(:"leaderboards", args))
end
player(args={}) click to toggle source

Fetches player, recommended that you webscrape for uuid before finding them.

# File lib/hypixel-ruby.rb, line 78
def player(args={})
  fetch(url(:"player", args))
end
session(args={}) click to toggle source
# File lib/hypixel-ruby.rb, line 82
def session(args={})
  fetch(url(:"session", args))
end
url(type, hash) click to toggle source

Builds a url from the request type and parameters. Do not specify your key in the parameters.

# File lib/hypixel-ruby.rb, line 29
def url(type, hash)
  url = "https://api.hypixel.net/"
  url << type.to_s
  url << "?key=" + @key
  hash.each do |a1, a2|
    url << "&" + a1.to_s + "=" + a2.to_s
  end
  return url
end
watchdogstats(args={}) click to toggle source

Gets info on bans/watchdog.

# File lib/hypixel-ruby.rb, line 87
def watchdogstats(args={})
  fetch(url(:"watchdogstats", args))
end