Giá vàng API
Giá trực tiếp của vàng, bạc, bạch kim, palladium và đồng, tỷ giá, lịch sử theo ngày và nến, qua các yêu cầu GET đơn giản với khóa API.
Tham chiếu
- URL gốc
- https://goldapi.dev/api/v1
- Xác thực
- Khóa của bạn trong header X-API-Key
- Định dạng phản hồi
- JSON
- Gói miễn phí
- 100 yêu cầu mỗi giờ, không cần thẻ
curl --fail-with-body --max-time 10 "https://goldapi.dev/api/v1/price/XAU/USD" \ -H "X-API-Key: $API_KEY"const res = await fetch("https://goldapi.dev/api/v1/price/XAU/USD", { headers: { "X-API-Key": process.env.API_KEY }, signal: AbortSignal.timeout(10_000),});if (!res.ok) throw new Error("HTTP " + res.status);console.log(await res.json());import os, requestsres = requests.get( "https://goldapi.dev/api/v1/price/XAU/USD", headers={"X-API-Key": os.environ["API_KEY"]}, timeout=10,)res.raise_for_status()print(res.json())package mainimport ( "fmt" "io" "net/http" "os" "time")func main() { client := http.Client{Timeout: 10 * time.Second} req, err := http.NewRequest("GET", "https://goldapi.dev/api/v1/price/XAU/USD", nil) if err != nil { panic(err) } req.Header.Set("X-API-Key", os.Getenv("API_KEY")) res, err := client.Do(req) if err != nil { panic(err) } defer res.Body.Close() body, err := io.ReadAll(res.Body) if err != nil { panic(err) } if res.StatusCode != 200 { panic(fmt.Sprintf("HTTP %d: %s", res.StatusCode, body)) } fmt.Println(string(body))}import java.io.IOException;import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.time.Duration;public class Main { public static void main(String[] args) throws Exception { HttpRequest request = HttpRequest.newBuilder(URI.create("https://goldapi.dev/api/v1/price/XAU/USD")) .header("X-API-Key", System.getenv("API_KEY")) .timeout(Duration.ofSeconds(10)) .build(); HttpResponse<String> response = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); if (response.statusCode() != 200) throw new IOException("HTTP " + response.statusCode()); System.out.println(response.body()); }}import Foundationvar request = URLRequest(url: URL(string: "https://goldapi.dev/api/v1/price/XAU/USD")!)request.setValue(ProcessInfo.processInfo.environment["API_KEY"], forHTTPHeaderField: "X-API-Key")request.timeoutInterval = 10let (data, response) = try await URLSession.shared.data(for: request)guard (response as? HTTPURLResponse)?.statusCode == 200 else { throw URLError(.badServerResponse) }print(String(data: data, encoding: .utf8)!)$context = stream_context_create(["http" => [ "header" => "X-API-Key: " . getenv("API_KEY"), "timeout" => 10,]]);$body = file_get_contents("https://goldapi.dev/api/v1/price/XAU/USD", false, $context);if ($body === false) throw new RuntimeException("Request failed");echo $body;Phản hồi 200
{
"symbol": "XAU",
"name": "Gold",
"currency": "USD",
"unit": "oz",
"price": 4072.1,
"gram": 130.921,
"karat": 24,
"updatedAt": "2026-11-07T02:39:04+02:00"
}
Một endpoint cho mỗi việc
Dữ liệu kim loại cho ứng dụng của bạn
Hướng dẫn thực tế
Câu hỏi thường gặp
API giá vàng có miễn phí không?
Có. Free bao gồm 100 yêu cầu mỗi giờ, giá giao ngay trực tiếp của vàng, bạc, đồng, bạch kim và palađi, cùng tỷ giá. Không cần thẻ tín dụng. Free cho phép sử dụng thương mại khi có liên kết hiển thị.
API này có phù hợp để lấy dữ liệu giá hàng hóa không?
Có. Mọi gói đều bao gồm giá giao ngay trực tiếp của vàng, bạc, đồng, bạch kim và palađi, cùng quy đổi sang các tiền tệ khác. Basic có giá $8/tháng, bổ sung lịch sử hàng ngày.
API lấy dữ liệu từ những nguồn nào?
Giá giao ngay đến từ nguồn dữ liệu thị trường của chúng tôi. Giá theo tiền tệ khác là giá giao ngay USD × tỷ giá trực tiếp, và vàng theo EGP còn theo thị trường nội địa Ai Cập. Mỗi phản hồi có thời điểm tính toán.
Có thể sử dụng thương mại không?
Mọi gói đều cho phép sử dụng thương mại. Free yêu cầu liên kết hiển thị đến goldapi.dev gần phần giá. Việc phân phối lại hoặc bán lại chính dữ liệu cần thỏa thuận riêng: [email protected].