Last active
August 18, 2017 20:42
-
-
Save Endogen/354942856d23fc4b682a7ee342213092 to your computer and use it in GitHub Desktop.
Choose which Kraken API keys to use depending on current MAC address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from uuid import getnode as mac | |
# Read Kraken keys | |
with open("kraken.json") as kraken_keys_file: | |
kraken_keys = json.load(kraken_keys_file) | |
# Identify and choose Kraken API keys based on MAC address | |
# and return the Kraken object to call the API | |
def get_kraken_api(): | |
if str(mac()) in kraken_keys: | |
api_key = kraken_keys[str(mac())]["api_key"] | |
private_key = kraken_keys[str(mac())]["private_key"] | |
else: | |
# If no entry found for current MAC address, use random one from config | |
msg = "No Kraken API keys found for MAC " + str(mac()) + ". Using random from config" | |
updater.bot.send_message(chat_id=config["user_id"], text=msg) | |
mac_address, keys_dict = random.choice(list(kraken_keys.items())) | |
api_key = keys_dict["api_key"] | |
private_key = keys_dict["private_key"] | |
# Connect to Kraken | |
return krakenex.API(key=api_key, secret=private_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The question is, how to get the MAC or any other unique identification of the connected client...