1. ขออัตราสองสกุล USD ใน path คือสกุลฐาน ส่วน EUR และ GBP ใน `symbols` คือสกุลปลายทาง เปลี่ยนรหัสได้ตามต้องการ
ใช้กับสแตกของคุณ คำขอเดียวกันใช้ได้กับ curl, Python และ JavaScript ไม่ต้องใช้ API key เพื่อทดลอง
เปิดคู่มือเริ่มต้น → curl Python JavaScript / Node.js
คัดลอกโค้ด curl -fsS --max-time 10 "https://api.exchangerate.dev/v1/latest/USD?symbols=EUR,GBP" from urllib.request import Request, urlopen
import json
# Identify your application explicitly when calling the API.
request = Request("https://api.exchangerate.dev/v1/latest/USD?symbols=EUR,GBP", headers={"User-Agent": "exchangerate-docs/1.0"})
with urlopen(request, timeout=10) as response:
data = json.load(response)
print(data["rates"]["EUR"]) const response = await fetch("https://api.exchangerate.dev/v1/latest/USD?symbols=EUR,GBP", {
signal: AbortSignal.timeout(10_000),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log(data.rates.EUR); ตัวอย่างการตอบกลับ {
"result": "success",
"base": "USD",
"source": "live",
"sources": {
"EUR": "live",
"GBP": "live"
},
"market_session": "open",
"timestamp": "2026-06-15T12:00:00Z",
"data_updated_at": "2026-06-15T12:00:00Z",
"effective_at": {
"EUR": "2026-06-15T12:00:00Z",
"GBP": "2026-06-15T12:00:00Z"
},
"rates": {
"EUR": 0.86207,
"GBP": 0.74627
},
"derived_symbols": [],
"notice": "Indicative rates, not for settlement."
} rates.EUR คือจำนวน EUR ต่อ 1 USD ส่วน effective_at.EUR คือเวลาที่สังเกต และ sources.EUR คือประเภทแหล่งข้อมูล ค่าและเวลาเป็นตัวอย่าง
Python → JavaScript / Node.js → Google Sheets → Excel → Go → Swift → Zapier → 2. อ่าน response ตัวเลขเปลี่ยนได้แต่โครงสร้างคงเดิม อ่าน `rates.EUR` และเก็บ `source`, `market_session`, `data_updated_at` ไปพร้อมกัน
json · exact example COPY
{
"result": "success",
"base": "USD",
"source": "live",
"sources": {
"EUR": "live",
"GBP": "live"
},
"market_session": "open",
"timestamp": "2026-06-15T12:00:00Z",
"data_updated_at": "2026-06-15T12:00:00Z",
"effective_at": {
"EUR": "2026-06-15T12:00:00Z",
"GBP": "2026-06-15T12:00:00Z"
},
"rates": {
"EUR": 0.86207,
"GBP": 0.74627
},
"derived_symbols": [],
"notice": "Indicative rates, not for settlement."
} 3. เพิ่มคีย์เมื่อใช้ quota ของบัญชี สร้างคีย์ฟรีแล้วส่งด้วย `Authorization: Bearer YOUR_KEY` เก็บคีย์ไว้ฝั่ง server ไม่ใส่ใน JavaScript สาธารณะ
bash · authenticated COPY
curl "https://api.exchangerate.dev/v1/latest/USD?symbols=EUR,GBP" -H "Authorization: Bearer YOUR_KEY" อัตราสำหรับอ้างอิง
เหมาะกับแอป โมเดล และการวิเคราะห์ ไม่ใช่ราคาซื้อขายหรือราคาชำระ