实时汇率兑换接口介绍

调用说明 调用示例 在线测试 实时汇率兑换
接口地址: https://ping.4759.cn/api/exchange.php
请求方式: GET / POST
返回格式: JSON
频率限制: 按APIKey等级限制每日调用额度 + 单IP1分钟限流
授权要求: 需携带有效的apikey参数
支持货币: 全球200+主流货币,支持中文名称输入:人民币、美元、欧元、日元、英镑等,无需记忆三位货币代码

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

调用说明

1. 请求参数

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

2. 返回参数

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

3. 状态码说明

调用示例

1. GET请求示例

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

2. POST请求示例(curl)

curl -X POST https://ping.4759.cn/api/exchange.php \ -d "apikey=key_123456&from=美元&to=人民币&amount=1"

3. PHP调用示例

<?php // +---------------------------------------------------------------------- // | 实时汇率兑换接口 PHP调用示例 // | 复制即可使用,需替换为自己的API Key // +---------------------------------------------------------------------- $apikey = '你的API授权码'; $from = '美元'; $to = '人民币'; $amount = '1'; $apiUrl = 'https://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, CURLOPT_FOLLOWLOCATION => true ]); $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 = '你的API授权码' from = 'USD' to = 'CNY' amount = 1 api_url = f'https://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 Exception as e: print("请求失败",e)

5. 成功返回JSON示例

{ "code": 200, "msg": "success", "data": { "from": "USD", "to": "CNY", "amount": 1, "rate": 7.1956, "result": 7.1956, "update_time": "2026-07-22 11:22:33" }, "usage": { "today_used": 8, "today_remaining": 992, "hourly_remaining": "无统计" } }

在线测试

填写参数后点击发起请求即可测试接口返回结果
服务器检测中...