freqtrade_origin/freqtrade/rpc/api_server2/api_v1.py
2021-01-03 06:46:25 +01:00

40 lines
1.1 KiB
Python

from freqtrade.rpc import RPC
from fastapi import APIRouter, Depends
from freqtrade import __version__
from .api_models import Balances, Ping, StatusMsg, Version
from .deps import get_config, get_rpc
# Public API, requires no auth.
router_public = APIRouter()
# Private API, protected by authentication
router = APIRouter()
@router_public.get('/ping', response_model=Ping)
def ping():
"""simple ping version"""
return {"status": "pong"}
@router.get('/version', response_model=Version, tags=['info'])
def version():
return {"version": __version__}
@router.get('/balance', response_model=Balances, tags=['info'])
def balance(rpc: RPC = Depends(get_rpc), config=Depends(get_config)):
return rpc._rpc_balance(config['stake_currency'], config.get('fiat_display_currency', ''),)
@router.post('/start', response_model=StatusMsg, tags=['botcontrol'])
def start(rpc: RPC = Depends(get_rpc)):
return rpc._rpc_start()
@router.post('/stop', response_model=StatusMsg, tags=['botcontrol'])
def stop(rpc: RPC = Depends(get_rpc)):
return rpc._rpc_stop()