new endpoint get_global_status
This commit is contained in:
parent
15b2cf5601
commit
574d8f82ef
32
main.py
32
main.py
|
|
@ -1,4 +1,3 @@
|
||||||
import libraries.balance_accounts as balance_accounts
|
|
||||||
from libraries.wrappers import earn_binance
|
from libraries.wrappers import earn_binance
|
||||||
from libraries.wrappers import earn_kucoin
|
from libraries.wrappers import earn_kucoin
|
||||||
from libraries.wrappers import earn_okx
|
from libraries.wrappers import earn_okx
|
||||||
|
|
@ -12,7 +11,6 @@ import time
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import socket
|
|
||||||
|
|
||||||
|
|
||||||
def load_keys_from_db(file_name: str) -> list:
|
def load_keys_from_db(file_name: str) -> list:
|
||||||
|
|
@ -118,6 +116,34 @@ def main():
|
||||||
|
|
||||||
earn_api = Flask(__name__)
|
earn_api = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@earn_api.route("/get_global_status", methods=['GET'])
|
||||||
|
def get_global_status():
|
||||||
|
'''
|
||||||
|
GET request
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
None
|
||||||
|
'''
|
||||||
|
|
||||||
|
if "X-API-KEY" in request.headers and request.headers.get("X-API-KEY") in valid_keys:
|
||||||
|
response = {}
|
||||||
|
for item in earners:
|
||||||
|
response[str(item.connector)] = {"trading_balance": item.get_trading_balance(),
|
||||||
|
"earning_balance": item.get_earning_balance(),
|
||||||
|
"is_paused": item.get_is_paused(),
|
||||||
|
"step_size": item.get_step_size(),
|
||||||
|
"percentage": item.get_percentage(),
|
||||||
|
"minimum_amount_in_trading_account": item.get_minimum_amount_in_trading_account(),
|
||||||
|
"time_between_subscriptions": item.get_time_between_subscriptions(),
|
||||||
|
"time_between_redemptions": item.get_time_between_redemptions(),
|
||||||
|
"last_subscription": item.get_last_subscription(),
|
||||||
|
"last_redemption": item.get_last_redemption()}
|
||||||
|
response["uptime"] = time.time() - start_time
|
||||||
|
return jsonify(response)
|
||||||
|
return jsonify({'Error': 'API key not valid'}), 401
|
||||||
|
|
||||||
|
|
||||||
@earn_api.route("/toggle_pause", methods=['POST'])
|
@earn_api.route("/toggle_pause", methods=['POST'])
|
||||||
def toggle_pause():
|
def toggle_pause():
|
||||||
'''
|
'''
|
||||||
|
|
@ -454,7 +480,7 @@ def run_API(port):
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
|
|
||||||
version = "2025.01.11"
|
version = "2025.01.29"
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
with open("config.json") as f:
|
with open("config.json") as f:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue