当日货币汇率
提供全球主要货币的实时汇率,支持美元、欧元、英镑、日元等常见币种的数据查询,帮您轻松完成外币汇率查询。
接口地址
http
https://api.nxvav.cn/api/exchange-rate/请求示例
Shell
curl --location --request GET "https://api.nxvav.cn/api/exchange-rate"JavaScript
var requestOptions = {
method: 'GET',
redirect: 'follow'
};
fetch("https://api.nxvav.cn/api/exchange-rate", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));Java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.get("https://api.nxvav.cn/api/exchange-rate")
.asString();Swift
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
var semaphore = DispatchSemaphore (value: 0)
var request = URLRequest(url: URL(string: "https://api.nxvav.cn/api/exchange-rate")!,timeoutInterval: Double.infinity)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
semaphore.signal()
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()Go
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.nxvav.cn/api/exchange-rate"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.nxvav.cn/api/exchange-rate',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;Python
import requests
url = "https://api.nxvav.cn/api/exchange-rate"
payload={}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)C
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.nxvav.cn/api/exchange-rate");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);C#
var client = new RestClient("https://api.nxvav.cn/api/exchange-rate");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);Ruby
require "uri"
require "net/http"
url = URI("https://api.nxvav.cn/api/exchange-rate")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
response = https.request(request)
puts response.read_body请求参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| currency | string | 否 | 货币代码,可以在 https://coinyep.com/zh/currencies 查询,默认为 CNY (人民币) |
| encoding | string | 否 | 编码方式,支持 text json markdown |
返回响应
| 字段名 | 类型 | 说明 |
|---|---|---|
| code | integer | 状态码 |
| message | string | 返回信息 |
| data | object | 返回数据 |
| base_code | string | 基准货币代码,默认为 CNY (人民币) |
| updated | string | 更新时间 |
| updated_at | integer | 更新时间,格式为时间戳(毫秒) |
| next_updated | string | 下次更新时间 |
| rates | array | 汇率数据,包含货币代码和对应汇率 |
| currency | string | 货币代码,例如 USD、EUR 等 |
| rate | integer/number | 对应货币的汇率 |
返回示例
json
{
"code": 200,
"message": "获取成功。数据来自官方/权威源头,以确保稳定与实时。",
"data": {
"base_code": "CNY",
"updated": "2025/11/17 08:02:32",
"updated_at": 1763337752000,
"next_updated": "2025/11/18 08:17:02",
"next_updated_at": 1763425022000,
"rates": [
{
"currency": "CNY",
"rate": 1
},
{
"currency": "AED",
"rate": 0.516828
},
{
"currency": "AFN",
"rate": 9.323724
},
{
"currency": "ALL",
"rate": 11.691294
},
{
"currency": "AMD",
"rate": 53.779007
},
{
"currency": "ANG",
"rate": 0.251905
},
{
"currency": "更多汇率...",
"rate": 0
}
]
}
}json
{
"code": 201,
"msg": "参数错误"
}