get_request / post_request
Usingget_request
, post_request
in backtest is not recommended.
Inputβ
- get_request
url
params: {key: value}
args
- post_request
url
data: {key: value}
json: {key: value}
args
Supported URLs (Third party APIs):
Exampleβ
url = "https://api.apilayer.com/currency_data/live?source=USD¤cies=EUR"
payload = {}
headers= {
"apikey": "[YOUR_API_KEY]"
}
response = CA.get_request(url, headers=headers, data=payload)
status_code = response.status_code
result = response.json()
CA.log(str(status_code))
CA.log(str(result))
CA.log(str(result['quotes']['USDEUR']))
logging:
200
{'success': True, 'timestamp': 1655851923, 'source': 'USD', 'quotes': {'USDEUR': 0.948897}}
0.948897