货币换算
官方换算接口,24小时实时货币汇率
接口信息
| 项目 | 内容 |
|---|---|
| 接口地址 | https://api.code410.com/api/convert/currency |
| 返回格式 | application/json |
| 请求方式 | HTTP GET POST/JSON |
| 更新日期 | 2024-10-03 |
| 调用权限 | 免费开放 |
| 每日限制 | 无限制 |
| 请求频率限制 | 1秒5次 |
请求示例
查询货币符号:https://api.code410.com/api/convert/currency?type=list 查询基准货币全表汇率:https://api.code410.com/api/convert/currency?money= CNY 点对点货币换算:https://api.code410.com/api/convert/currency?from= USD &to= CNY &amount= 100请求 HEADER
| 名称 | 值 |
|---|---|
| Content-Type | application/x-www-form-urlencoded;charset; |
请求参数说明
| 名称 | 必填 | 类型 | 示例值 | 说明 |
|---|---|---|---|---|
| type | 否 | string | list | 【type=list】返回支持的所有币种代码与中文名(共 166 个) |
| money | 否 | string | CNY | 基准货币代码,未传默认 CNY;返回该基准对全部币种的汇率全表 |
| from | 否 | string | USD | 点对点换算的源币种;与 to/amount 配合使用,未传默认沿用 money 或 CNY |
| to | 否 | string | CNY | 点对点换算的目标币种;不传则返回全表,传则只返回换算结果 |
| amount | 否 | number | 100 | 需要换算的金额,仅在 from + to 模式下生效,默认 1 |
返回参数说明
| 名称 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码 |
| msg | string | 状态信息 |
| data | object/string | 请求结果数据集,详见下文两种模式 |
| data.From | string | 【全表模式】基准货币代码 |
| data.To | object | 【全表模式】基准货币 1 单位对应各币种的汇率字典 |
| data.update_time | string | 上游汇率最近更新时间(UTC) |
| data.from / data.to | string | 【点对点模式】源/目标币种代码 |
| data.from_name / data.to_name | string | 【点对点模式】源/目标币种中文名 |
| data.amount | number | 【点对点模式】请求换算金额 |
| data.rate | number | 【点对点模式】1 单位 from 兑换成 to 的汇率 |
| data.result | number | 【点对点模式】amount × rate 的换算结果 |
| exec_time | float | 执行耗时 |
| user_ip | string | 客户端 IP |
错误码参照
| 错误码 | 类型 | 说明 |
|---|---|---|
| 403 | int | 没有权限 |
| 400 | int | 参数传递不正确 |
| 500 | int | 服务器内部错误 |
在线调试 / 完整文档
本接口为 信息查找 分类下的开放接口。完整文档、在线调试与示例代码请前往 https://api.code410.com/doc/220。
返回示例
{
"code": 200,
"msg": "请求成功",
"data": {
"From": "CNY",
"To": {
"CNY": 1,
"AED": 0.54074,
"AFN": 9.395226,
"ALL": 12.075853,
"AMD": 54.265626,
"ANG": 0.26356,
"AOA": 139.687,
"ARS": 212.381519,
"AUD": 0.208005,
"AWG": 0.26356,
"AZN": 0.250183,
"BAM": 0.248969,
"BBD": 0.294481,
"BDT": 18.069979,
"BGN": 0.248969,
"BHD": 0.055362,
"BIF": 439.675789,
"BMD": 0.14724,
"BND": 0.189423,
"BOB": 1.019157,
"BRL": 0.747272,
"BSD": 0.14724,
"BTN": 14.133477,
"BWP": 2.138929,
"BYN": 0.412672,
"BZD": 0.294481,
"CAD": 0.204786,
"CDF": 336.129379,
"CHF": 0.116886,
"CLF": 0.003334,
"CLP": 131.797173,
"CNH": 0.99955,
"COP": 525.418336,
"CRC": 67.518947,
"CUP": 3.533766,
"CVE": 14.036268,
"CZK": 3.075031,
"DJF": 26.167685,
"DKK": 0.949675,
"DOP": 8.559107,
"DZD": 19.620317,
"EGP": 7.630172,
"ERN": 2.208604,
"ETB": 23.573068,
"EUR": 0.127297,
"FJD": 0.323472,
"FKP": 0.109988,
"FOK": 0.949675,
"GBP": 0.109989,
"GEL": 0.391931,
"GGP": 0.109988,
"GHS": 1.735474,
"GIP": 0.109988,
"GMD": 10.922328,
"GNF": 1290.502922,
"GTQ": 1.121756,
"GYD": 30.784573,
"HKD": 1.153333,
"HNL": 3.915841,
"HRK": 0.95911,
"HTG": 19.231674,
"HUF": 44.792833,
"IDR": 2659.574468,
"ILS": 0.431126,
"IMP": 0.109988,
"INR": 14.133477,
"IQD": 192.921857,
"IRR": 173565.360238,
"ISK": 18.178508,
"JEP": 0.109988,
"JMD": 23.206784,
"JOD": 0.104393,
"JPY": 23.597481,
"KES": 19.08,
"KGS": 12.875342,
"KHR": 594.177065,
"KID": 0.207999,
"KMF": 62.625411,
"KRW": 226.295542,
"KWD": 0.04529,
"KYD": 0.1227,
"KZT": 71.575619,
"LAK": 3224.451727,
"LBP": 13178.002551,
"LKR": 49.616,
"LRD": 26.86037,
"LSL": 2.413635,
"LYD": 0.937063,
"MAD": 1.353969,
"MDL": 2.547421,
"MGA": 618.0048,
"MKD": 7.801214,
"MMK": 309.06472,
"MNT": 528.262018,
"MOP": 1.187927,
"MRU": 5.894822,
"MUR": 6.977834,
"MVR": 2.272503,
"MWK": 256.773611,
"MXN": 2.541296,
"MYR": 0.590388,
"MZN": 9.357506,
"NAD": 2.413635,
"NGN": 200.368168,
"NIO": 5.41377,
"NOK": 1.385216,
"NPR": 22.613562,
"NZD": 0.253761,
"OMR": 0.056613,
"PAB": 0.14724,
"PEN": 0.505179,
"PGK": 0.642955,
"PHP": 9.082652,
"PKR": 41.108279,
"PLN": 0.539419,
"PYG": 897.85136,
"QAR": 0.535955,
"RON": 0.6652,
"RSD": 14.915578,
"RUB": 10.834236,
"RWF": 216.071532,
"SAR": 0.552151,
"SBD": 1.165281,
"SCR": 2.170034,
"SDG": 74.816103,
"SEK": 1.389037,
"SGD": 0.189424,
"SHP": 0.109988,
"SLE": 3.615806,
"SLL": 3615.786438,
"SOS": 84.098747,
"SRD": 5.472248,
"SSP": 693.149697,
"STN": 3.118746,
"SYP": 16.760487,
"SZL": 2.413635,
"THB": 4.824428,
"TJS": 1.364816,
"TMT": 0.515265,
"TND": 0.429979,
"TOP": 0.346988,
"TRY": 6.775068,
"TTD": 0.99392,
"TVD": 0.207999,
"TWD": 4.651163,
"TZS": 385.195442,
"UAH": 6.533346,
"UGX": 549.774349,
"USD": 0.147241,
"UYU": 5.929529,
"UZS": 1766.684894,
"VES": 83.914678,
"VND": 3891.050584,
"VUV": 17.411913,
"WST": 0.395284,
"XAF": 83.500548,
"XCD": 0.397549,
"XCG": 0.26356,
"XDR": 0.107652,
"XOF": 83.500548,
"XPF": 15.190458,
"YER": 35.092384,
"ZAR": 2.413688,
"ZMW": 2.608523,
"ZWG": 3.943845,
"ZWL": 3.943866
},
"update_time": "Sun, 07 Jun 2026 00:02:31 +0000"
},
"exec_time": 0.006,
"ip": "197.149.235.178"
}示例代码
// jQuery-Ajax
$.ajax({
url: 'https://api.code410.com/api/convert/currency',
data: {
type: "list",
money: "CNY",
from: "USD",
to: "CNY",
amount: "100",
},
type: 'GET',
dataType: 'json',
success: function (data) {
console.log(data); // 请求成功,输出结果
},
error: function () {
console.log('请求失败');
}
});import requests
url = "https://api.code410.com/api/convert/currency"
params = {
"type": "list",
"money": "CNY",
"from": "USD",
"to": "CNY",
"amount": "100",
}
res = requests.get(url, params=params)
print(res.json())const https = require('https');
const url = 'https://api.code410.com/api/convert/currency?type=list&money=CNY&from=USD&to=CNY&amount=100';
https.get(url, res => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => console.log(JSON.parse(data)));
}).on('error', err => console.error(err));package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
resp, err := http.Get("https://api.code410.com/api/convert/currency?type=list&money=CNY&from=USD&to=CNY&amount=100")
if err != nil {
fmt.Println("http get error", err)
return
}
defer resp.Body.Close()
result, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(result))
}import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Test {
public static void main(String[] args) {
try {
URL url = new URL("https://api.code410.com/api/convert/currency?type=list&money=CNY&from=USD&to=CNY&amount=100");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.connect();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line;
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null) sb.append(line);
reader.close();
System.out.println(sb.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program {
static async Task Main() {
HttpClient client = new HttpClient();
string url = "https://api.code410.com/api/convert/currency?type=list&money=CNY&from=USD&to=CNY&amount=100";
HttpResponseMessage response = await client.GetAsync(url);
string body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
}<?php
$url = "https://api.code410.com/api/convert/currency?type=list&money=CNY&from=USD&to=CNY&amount=100";
$response = file_get_contents($url);
$data = json_decode($response, true);
print_r($data);curl "https://api.code410.com/api/convert/currency?type=list&money=CNY&from=USD&to=CNY&amount=100"在线调试
填写参数后点击「发起请求」查看实时返回结果。
