实时汇率兑换接口介绍

调用说明 调用示例 在线测试 实时汇率兑换
接口地址: http://ping.4759.cn/api/exchange.php
请求方式: GET / POST
返回格式: JSON
频率限制: 单APIKey每分钟50次
授权要求: 需携带有效的apikey参数
支持货币: 全球200+主流货币(USD、CNY、EUR、GBP、JPY等,支持中文名称人民币/美元/欧元)

本API提供实时汇率查询与货币兑换服务,支持全球200+种法定货币实时转换,数据实时更新,稳定高可用。
注意:调用接口必须携带有效的API授权码(apikey),未授权访问将被拦截。

调用说明

1. 请求参数

参数名 必选 类型 说明 示例值
apikey string API授权码(需申请有效授权码) key_123456
from string 源货币代码 USD(美元)、CNY(人民币)
to string 目标货币代码 CNY、EUR、GBP
amount number 兑换金额(数字) 1、100、99.99

2. 返回参数

参数名 类型 说明
code int 状态码:200成功,400参数错误,401授权无效,403禁用/过期/限流,500服务器错误
msg string 返回信息描述
data object 汇率结果(失败为null)
data.from string 源货币代码
data.to string 目标货币代码
data.amount string 原始金额
data.rate string 实时汇率
data.result string 兑换结果金额
data.update_time string 更新时间
usage object 调用次数统计
usage.today_used int 今日已用次数
usage.today_remaining int 今日剩余次数
usage.hourly_remaining int 小时剩余次数

3. 状态码说明

调用示例

1. GET请求示例

http://ping.4759.cn/api/exchange.php?apikey=key_123456&from=USD&to=CNY&amount=1

2. POST请求示例(curl)

curl -X POST http://ping.4759.cn/api/exchange.php \ -d "apikey=key_123456&from=USD&to=CNY&amount=1"

3. PHP调用示例

<?php // +---------------------------------------------------------------------- // | 实时汇率兑换接口 PHP调用示例 // | 复制即可使用,需替换为自己的API Key // +---------------------------------------------------------------------- $apikey = 'key_123456'; $from = 'USD'; $to = 'CNY'; $amount = '1'; $apiUrl = 'http://ping.4759.cn/api/exchange.php?apikey='.urlencode($apikey). '&from='.urlencode($from).'&to='.urlencode($to).'&amount='.urlencode($amount); $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL => $apiUrl, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10, CURLOPT_SSL_VERIFYPEER => false ]); $response = curl_exec($ch); curl_close($ch); $result = json_decode($response, true); if ($result['code'] == 200) { echo "源货币: " . $result['data']['from'] . "\n"; echo "目标货币: " . $result['data']['to'] . "\n"; echo "实时汇率: " . $result['data']['rate'] . "\n"; echo "兑换结果: " . $result['data']['result'] . "\n"; } else { echo "错误: " . $result['msg']; } ?>

4. Python调用示例

import requests apikey = 'key_123456' from = 'USD' to = 'CNY' amount = 1 api_url = f'http://ping.4759.cn/api/exchange.php?apikey={apikey}&from={from}&to={to}&amount={amount}' try: response = requests.get(api_url, timeout=10) result = response.json() print(result) except: print("请求失败")

5. 返回结果示例

{ "code": 200, "msg": "success", "data": { "from": "USD", "to": "CNY", "amount": "1", "rate": "7.1956", "result": "7.1956", "update_time": "2025-12-20 11:22:33" }, "usage": { "today_used": 8, "today_remaining": 992, "hourly_remaining": 42 } }

在线测试

填写授权码后点击发起请求...
服务器检测中...