接入教程
如何使用汇率主机API导入外汇汇率到Google表格
Python示例:获取实时汇率
python
import requests
url = 'https://api.exchangerate.host/latest?base=USD'
response = requests.get(url)
data = response.json()
print(data)
PHP示例:获取历史汇率
php
<?php
$url = 'https://api.exchangerate.host/2020-01-01?base=USD';
$data = file_get_contents($url);
$json = json_decode($data, true);
print_r($json);
?>
JavaScript示例:货币转换
javascript
fetch('https://api.exchangerate.host/convert?from=USD&to=EUR&amount=100')
.then(response => response.json())
.then(data => console.log(data));
常见问题
汇率主机的API是什么?
汇率主机的API是一个REST API,提供实时和历史的外汇及加密货币汇率数据服务。
API的可用性如何?
API的系统状态全天候监控,过去12个月的平均可用性为99.9%。
Aitishiku.com