How to use hypixel - 10 common examples

To help you get started, we’ve selected a few hypixel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Snuggle / hypixel.py / tests / speed.py View on Github external
import hypixel
from time import time
from random import shuffle

print("Test \"{}\" is now running...\n".format(os.path.basename(__file__)))

API_KEY = os.environ['apikey']

hypixel.setKeys([API_KEY])

start = time() # Start timer.

for i in range(0, Repeats-1):
    shuffle(ActualData) # Randomize the order of the data
    for InputUUID in ActualData:
        Player = hypixel.Player(InputUUID)
        print(Player.getPlayerInfo())

end = time()

totalTime = start-end

print("\nDone! Speed test finished. Time taken: {}".format(end-start))
github Snuggle / hypixel.py / tests.py View on Github external
""" Travis Ci Tests """
import os
import hypixel
import time

API_KEY = os.environ['apikey']

start = time.time()

hypixel.setKeys([API_KEY])
Snuggle = hypixel.Player('8998bcff9765438bb6089ab93bfad4d3')

SnuggleLevel = Snuggle.getLevel()
if SnuggleLevel > 0:
    print("Snuggle's is level {}.".format(SnuggleLevel))
else:
    raise ValueError(SnuggleLevel)

SnuggleRank = Snuggle.getRank()
if SnuggleRank['rank'] == "Moderator":
    print("Snuggle's is a {}.".format(SnuggleRank))
else:
    raise ValueError(SnuggleRank)

SnuggleKarma = Snuggle.JSON['karma']
if SnuggleKarma > 0:
    print("Snuggle has {} karma.".format(SnuggleKarma))
github Snuggle / hypixel.py / tests / player.py View on Github external
import os
import sys
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import hypixel
import time

print("Test \"{}\" is now running...\n".format(os.path.basename(__file__)))

API_KEY = os.environ['apikey']

hypixel.setKeys([API_KEY])

TestFailed = False

for player in ActualData:
    TestPlayer = hypixel.Player(player['Name'])
    for test in player:
        method_to_call = getattr(TestPlayer, 'get' + test)
        testdata = method_to_call()
        if testdata == player[test]:
            print("\U00002714 {}".format(testdata))
        else:
            print("\U0000274C {}, Expected: {} [FAILED]".format(testdata, player[test]))
            TestFailed = True
    print("UUID: {}\n".format(TestPlayer.UUID))

if TestFailed is True:
    raise ValueError


print("\nDone! All tests finished.")
github Snuggle / hypixel.py / tests / speed.py View on Github external
'b80a30a6d6d7472490c0c6081684b769']

Repeats = 5

import os
import sys
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import hypixel
from time import time
from random import shuffle

print("Test \"{}\" is now running...\n".format(os.path.basename(__file__)))

API_KEY = os.environ['apikey']

hypixel.setKeys([API_KEY])

start = time() # Start timer.

for i in range(0, Repeats-1):
    shuffle(ActualData) # Randomize the order of the data
    for InputUUID in ActualData:
        Player = hypixel.Player(InputUUID)
        print(Player.getPlayerInfo())

end = time()

totalTime = start-end

print("\nDone! Speed test finished. Time taken: {}".format(end-start))
github Snuggle / hypixel.py / tests / player.py View on Github external
'Level': 5.1,
               'GuildID': None,
               'Session': None}
              ]

import os
import sys
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import hypixel
import time

print("Test \"{}\" is now running...\n".format(os.path.basename(__file__)))

API_KEY = os.environ['apikey']

hypixel.setKeys([API_KEY])

TestFailed = False

for player in ActualData:
    TestPlayer = hypixel.Player(player['Name'])
    for test in player:
        method_to_call = getattr(TestPlayer, 'get' + test)
        testdata = method_to_call()
        if testdata == player[test]:
            print("\U00002714 {}".format(testdata))
        else:
            print("\U0000274C {}, Expected: {} [FAILED]".format(testdata, player[test]))
            TestFailed = True
    print("UUID: {}\n".format(TestPlayer.UUID))

if TestFailed is True:
github Snuggle / hypixel.py / tests.py View on Github external
""" Travis Ci Tests """
import os
import hypixel
import time

API_KEY = os.environ['apikey']

start = time.time()

hypixel.setKeys([API_KEY])
Snuggle = hypixel.Player('8998bcff9765438bb6089ab93bfad4d3')

SnuggleLevel = Snuggle.getLevel()
if SnuggleLevel > 0:
    print("Snuggle's is level {}.".format(SnuggleLevel))
else:
    raise ValueError(SnuggleLevel)

SnuggleRank = Snuggle.getRank()
if SnuggleRank['rank'] == "Moderator":
    print("Snuggle's is a {}.".format(SnuggleRank))
else:
    raise ValueError(SnuggleRank)

SnuggleKarma = Snuggle.JSON['karma']
if SnuggleKarma > 0:
github Snuggle / hypixel.py / tests.py View on Github external
raise ValueError(SnuggleLevel)

SnuggleRank = Snuggle.getRank()
if SnuggleRank['rank'] == "Moderator":
    print("Snuggle's is a {}.".format(SnuggleRank))
else:
    raise ValueError(SnuggleRank)

SnuggleKarma = Snuggle.JSON['karma']
if SnuggleKarma > 0:
    print("Snuggle has {} karma.".format(SnuggleKarma))
else:
    raise ValueError(SnuggleKarma)

SnuggleGuildID = Snuggle.getGuildID()
SnuggleGuild = hypixel.Guild(SnuggleGuildID)
print("Snuggle's guild is called {}.".format(SnuggleGuild.JSON['name']))

end = time.time()
totalTime=end-start

print("\nDone! All tests finished successfully. Time taken: {}".format(totalTime))
github Snuggle / hypixel.py / hypixel.py View on Github external
def getPlayerInfo(self):
        """ This is a simple function to return a bunch of common data about a player. """
        JSON = self.JSON
        playerInfo = {}
        playerInfo['uuid'] = self.UUID
        playerInfo['displayName'] = Player.getName(self)
        playerInfo['rank'] = Player.getRank(self)
        playerInfo['networkLevel'] = Player.getLevel(self)
        JSONKeys = ['karma', 'firstLogin', 'lastLogin',
                    'mcVersionRp', 'networkExp', 'socialMedia', 'prefix']
        for item in JSONKeys:
            try:
                playerInfo[item] = JSON[item]
            except KeyError:
                pass
        return playerInfo
github Snuggle / hypixel.py / hypixel.py View on Github external
def getPlayerInfo(self):
        """ This is a simple function to return a bunch of common data about a player. """
        JSON = self.JSON
        playerInfo = {}
        playerInfo['uuid'] = self.UUID
        playerInfo['displayName'] = Player.getName(self)
        playerInfo['rank'] = Player.getRank(self)
        playerInfo['networkLevel'] = Player.getLevel(self)
        JSONKeys = ['karma', 'firstLogin', 'lastLogin',
                    'mcVersionRp', 'networkExp', 'socialMedia', 'prefix']
        for item in JSONKeys:
            try:
                playerInfo[item] = JSON[item]
            except KeyError:
                pass
        return playerInfo
github Snuggle / hypixel.py / .examples / simpleExample.py View on Github external
""" This is an example of how you can use this API to create cool things.
    Just run this and you should see cool stuff. c:"""

import hypixel

API_KEYS = ['API_KEY_HERE_PLS']
hypixel.setKeys(API_KEYS) # This sets the API keys that are going to be used.

Player = hypixel.Player('Snuggle') # This creates a Player-object and puts it to a variable called "Player".

PlayerName = Player.getName() # This gets the player's name and puts it in a variable called "PlayerName". :3
print("Player is called ", end='')
print(PlayerName)

PlayerLevel = Player.getLevel()
print(PlayerName + " is level: ", end='')
print(PlayerLevel) # This prints the level that we got, two lines up!

PlayerRank = Player.getRank()
print(PlayerName + " is rank: ", end='')
print(PlayerRank['rank'])