Python 我应该如何在类中放置必要的变量以从apiden获取数据?

Python 我应该如何在类中放置必要的变量以从apiden获取数据?,python,api,request,Python,Api,Request,我正在从api中提取数据。我正在为此创建一个类。但我不知道从api中提取数据所需的变量在哪里,也不知道我采用的管理方法是否是最好的方法。 我做了很多研究并尝试了。但我还是很困惑。从apiden发出请求所需的所有变量都在类和类的函数中定义。我将在类中的多个函数中使用这些变量。我每次都得一遍又一遍地重写,还是有更好的方法 class Balance: apiKey = "b306a0d1" apiSecret = "

我正在从api中提取数据。我正在为此创建一个类。但我不知道从api中提取数据所需的变量在哪里,也不知道我采用的管理方法是否是最好的方法。 我做了很多研究并尝试了。但我还是很困惑。从apiden发出请求所需的所有变量都在类和类的函数中定义。我将在类中的多个函数中使用这些变量。我每次都得一遍又一遍地重写,还是有更好的方法

    class Balance:
            apiKey = "b306a0d1"
            apiSecret = "OFGkl"
            base = "https://api.btcturk.com"
            method_balance = "/api/v1/users/balances"
            order_method = "/api/v1/order"

            def asset_list(self):
                    stamp = str(int(time.time())*1000)
                    data = "{}{}".format(apiKey, stamp).encode("utf-8")
                    signature = hmac.new(apiSecret, data, hashlib.sha256).digest()
                    signature = base64.b64encode(signature)
                    headers = {"X-PCK": apiKey, "X-Stamp": stamp, "X-Signature": signature, "Content-Type" : "application/json"}
                    result = requests.get(url=uri, headers=headers)
                    result = result.json()
                    data = result["data"]