mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Add ping endpoing
This commit is contained in:
parent
904ae5af91
commit
75d5ff69ef
|
@ -22,7 +22,14 @@ Sample configuration:
|
|||
!!! Danger "Password selection"
|
||||
Please make sure to select a very strong, unique password to protect your bot from unauthorized access.
|
||||
|
||||
You can then access the API by going to `http://127.0.0.1:8080/api/v1/version` to check if the API is running correctly.
|
||||
You can then access the API by going to `http://127.0.0.1:8080/api/v1/ping` to check if the API is running correctly.
|
||||
This should return the response:
|
||||
|
||||
``` output
|
||||
{"status":"pong"}
|
||||
```
|
||||
|
||||
All other endpoints will require authentication, so are not available through a webrowser.
|
||||
|
||||
To generate a secure password, either use a password manager, or use the below code snipped.
|
||||
|
||||
|
|
|
@ -169,6 +169,8 @@ class ApiServer(RPC):
|
|||
view_func=self._status, methods=['GET'])
|
||||
self.app.add_url_rule(f'{BASE_URI}/version', 'version',
|
||||
view_func=self._version, methods=['GET'])
|
||||
self.app.add_url_rule(f'{BASE_URI}/ping', 'ping',
|
||||
view_func=self._ping, methods=['GET'])
|
||||
|
||||
# Combined actions and infos
|
||||
self.app.add_url_rule(f'{BASE_URI}/blacklist', 'blacklist', view_func=self._blacklist,
|
||||
|
@ -224,6 +226,13 @@ class ApiServer(RPC):
|
|||
msg = self._rpc_stopbuy()
|
||||
return self.rest_dump(msg)
|
||||
|
||||
@rpc_catch_errors
|
||||
def _ping(self):
|
||||
"""
|
||||
simple poing version
|
||||
"""
|
||||
return self.rest_dump({"status": "pong"})
|
||||
|
||||
@require_login
|
||||
@rpc_catch_errors
|
||||
def _version(self):
|
||||
|
|
|
@ -64,6 +64,10 @@ def test_api_not_found(botclient):
|
|||
|
||||
def test_api_unauthorized(botclient):
|
||||
ftbot, client = botclient
|
||||
rc = client.get(f"{BASE_URI}/ping")
|
||||
assert_response(rc)
|
||||
assert rc.json == {'status': 'pong'}
|
||||
|
||||
# Don't send user/pass information
|
||||
rc = client.get(f"{BASE_URI}/version")
|
||||
assert_response(rc, 401)
|
||||
|
|
Loading…
Reference in New Issue
Block a user