빠른 시작
몇 분 안에 실시간 XAU/USD 가격을 받으세요.
시작하기 전에
curl 등의 HTTP 클라이언트와 무료 API 키가 필요합니다. 가입하고 이메일을 확인한 뒤 계정에서 키를 복사하세요. 무료 요금제는 시간당 100회 요청을 포함합니다.
첫 요청
X-API-Key 헤더로 키를 보내세요. 키는 서버에 보관하고 방문자가 볼 수 있는 코드에 넣지 마세요.
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;응답 읽기
price 는 응답 단위당 가격으로 트로이온스(구리는 파운드)입니다. gram 은 응답의 순도 기준 1그램 가격이고, updatedAt 은 응답이 만들어진 시각입니다.
응답 200
{
"symbol": "XAU",
"name": "Gold",
"currency": "USD",
"unit": "oz",
"price": 4072.1,
"gram": 130.921,
"karat": 24,
"updatedAt": "2026-11-07T02:39:10+02:00"
}
문제가 생기면
오류는 error 필드가 있는 JSON입니다. 흔한 오류는 헤더가 없을 때의 401 api_key_required, 키가 틀릴 때의 401 invalid_api_key, 이메일 확인 전의 403 email_not_verified 입니다. 제한을 넘으면 Retry-After 헤더와 함께 429 rate_limit_exceeded 를 받습니다.