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
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
Fetches boosters and their active times.
# File lib/hypixel-ruby.rb, line 48 def boosters(args={}) fetch(url(:"boosters", args)) end
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
Finds a guild by name or player.
# File lib/hypixel-ruby.rb, line 53 def findguild(args={}) fetch(url(:"findguild", args)) end
Refer to PublicAPI docs on this one.
# File lib/hypixel-ruby.rb, line 58 def friends(args={}) fetch(url(:"friends", args)) end
Fetches guild data by id.
# File lib/hypixel-ruby.rb, line 63 def guild(args={}) fetch(url(:"guild", args)) end
Fetches info about current status of API key.
# File lib/hypixel-ruby.rb, line 68 def key(args={}) fetch(url(:"key", args)) end
Gets top players in each game.
# File lib/hypixel-ruby.rb, line 73 def leaderboards(args={}) fetch(url(:"leaderboards", args)) end
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
# File lib/hypixel-ruby.rb, line 82 def session(args={}) fetch(url(:"session", args)) end
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
Gets info on bans/watchdog.
# File lib/hypixel-ruby.rb, line 87 def watchdogstats(args={}) fetch(url(:"watchdogstats", args)) end