freqtrade_origin/freqtrade/rpc/api_server2/api_v1.py

31 lines
719 B
Python
Raw Normal View History

from fastapi import APIRouter, Depends
2020-12-25 12:11:01 +00:00
from freqtrade import __version__
from .deps import get_config, get_rpc
from .models import Balances, Ping, Version
# Public API, requires no auth.
router_public = APIRouter()
2020-12-25 12:11:01 +00:00
# Private API, protected by authentication
router = APIRouter()
@router_public.get('/ping', response_model=Ping)
def ping():
"""simple ping version"""
return {"status": "pong"}
2020-12-25 14:57:05 +00:00
@router.get('/version', response_model=Version)
def version():
return {"version": __version__}
@router.get('/balance', response_model=Balances)
2020-12-25 12:11:01 +00:00
def balance(rpc=Depends(get_rpc), config=Depends(get_config)):
return rpc._rpc_balance(config['stake_currency'], config.get('fiat_display_currency', ''),)
2020-12-25 12:11:01 +00:00