INNER CODE UNIT · Python

_requestExchangeRate

adminho/trading-stock-thailand · BOT_API_example.py:82

def _requestExchangeRate(url, start_date, end_date):
	# url = "https://iapi.bot.or.th/Stat/Stat-ReferenceRate/DAILY_REF_RATE_V1/"
	# querystring = {"start_period":"2017-01-12","end_period":"2017-01-15"}
	querystring = {"start_period":start_date,"end_period":end_date}
	headers = {
		'api-key': "U9G1L457H6DCugT7VmBaEacbHV9RX0PySO05cYaGsm"
	}
	response = requests.request("GET", url, headers=headers, params=querystring)
	json_text = response.text
	
	"""
	Response example: 
	{"result":{
			"success":"true",
			"api":"Daily Weighted-average Interbank Exchange Rate - THB / USD",
			"timestamp":"2017-07-20 23:56:06",
			"data":{
					"data_header":{

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…