Documentation
Documentation
Contents
Documentation - Getting Started
Access precious metals pricing data through our comprehensive REST API. Get started in minutes with straightforward authentication and well-documented endpoints.
Overview
The FreeGoldPrice API provides indicative prices for four precious metals: Gold (XAU), Silver (XAG), Platinum (XPT), and Palladium (XPD). Our service supports 163 global currencies and delivers data in both JSON and XML formats.
API Versions
V2 is recommended for new integrations (multi-metal, multiple formats). V1 remains available for legacy support (one metal per call).
💰 Every successful request costs 1 credit.
For existing integrations using older endpoints, please refer to our Legacy API Quick-Start section.
Read Before You Integrate
Important Disclaimers
- Data Origin: Our prices are calculated from scraped and aggregated sources. Data is not audited per tick and may contain delays or inaccuracies.
- Trading Suitability: This API is NOT suitable for real-time trading, high-frequency applications, or mission-critical financial systems.
- User Responsibility: You purchase server requests, not guaranteed data accuracy. Users accept full responsibility for data usage and decision-making.
- No Liability: We provide no warranties and accept no liability for financial losses resulting from data usage.
- Investment Advice: This service does not constitute investment advice. Consult licensed financial advisors for investment decisions.
Authentication
Our API uses simple query-string authentication. Include your API key in every request using the key
parameter:
?key=YOUR_API_KEY
Authentication Requirements
- • Header-based authentication is NOT supported
- • API keys are bound to your account and credit balance
- • Each successful request costs 1 credit
- • Requests will fail when you have zero credits remaining
Don't have an API key? Sign up for free to get started immediately.
API V2 (Recommended)
Base URL pattern: GET /api/v2?key=[API_KEY]&action=[ACTION]
Available Actions
Action | Metals | Format | Unit | Description |
---|---|---|---|---|
GSX | Gold, Silver | XML | Ounce | Gold & Silver prices per ounce (XML) |
GSJ | Gold, Silver | JSON | Ounce | Gold & Silver prices per ounce (JSON) |
GSXM | Gold, Silver | XML | Gram | Gold & Silver prices per gram (XML) |
GSJM | Gold, Silver | JSON | Gram | Gold & Silver prices per gram (JSON) |
PPX | Platinum, Palladium | XML | Ounce | Platinum & Palladium per ounce (XML) |
PPJ | Platinum, Palladium | JSON | Ounce | Platinum & Palladium per ounce (JSON) |
PPXM | Platinum, Palladium | XML | Gram | Platinum & Palladium per gram (XML) |
PPJM | Platinum, Palladium | JSON | Gram | Platinum & Palladium per gram (JSON) |
GSPPX | All Four Metals | XML | Ounce | All metals prices per ounce (XML) |
GSPPJ | All Four Metals | JSON | Ounce | All metals prices per ounce (JSON) |
GSPPXM | All Four Metals | XML | Gram | All metals prices per gram (XML) |
GSPPJM | All Four Metals | JSON | Gram | All metals prices per gram (JSON) |
Response Examples
XML Response (GSX - Gold & Silver per ounce)
<?xml version="1.0" encoding="UTF-8"?>
<metals>
<date>2024-01-15T14:30:00Z</date>
<unit>ounce</unit>
<gold>
<USD>
<ask>2024.50</ask>
<bid>2022.75</bid>
</USD>
<EUR>
<ask>1836.20</ask>
<bid>1834.65</bid>
</EUR>
</gold>
<silver>
<USD>
<ask>24.85</ask>
<bid>24.78</bid>
</USD>
<EUR>
<ask>22.56</ask>
<bid>22.51</bid>
</EUR>
</silver>
</metals>
JSON Response (GSJ - Gold & Silver per ounce)
{
"date": "2024-01-15T14:30:00Z",
"unit": "ounce",
"gold": {
"USD": {
"ask": 2024.50,
"bid": 2022.75
},
"EUR": {
"ask": 1836.20,
"bid": 1834.65
}
},
"silver": {
"USD": {
"ask": 24.85,
"bid": 24.78
},
"EUR": {
"ask": 22.56,
"bid": 22.51
}
}
}
API V1 (Legacy)
Base URL pattern: GET /api/v1?key=[API_KEY]&action=[ACTION]
Note: Actions without "O" suffix return gram-based prices. Actions with "O" suffix return ounce-based prices.
Available Patterns
Pattern | Description |
---|---|
[Metal]JB | JSON bid price per gram |
[Metal]JBA | JSON bid & ask prices per gram |
[Metal]JBO | JSON bid price per ounce |
[Metal]JBAO | JSON bid & ask prices per ounce |
[Metal]BE | XML bid price per gram |
[Metal]BAE | XML bid & ask prices per gram |
[Metal]BOE | XML bid price per ounce |
[Metal]BAOE | XML bid & ask prices per ounce |
JMarketPrices | JSON all metals market prices |
MarketPrices | XML all metals market prices |
JSON Example (GoldJBA - per gram, bid & ask)
{
"gold": {
"USD": {
"bid": 65.02,
"ask": 65.08
},
"EUR": {
"bid": 59.05,
"ask": 59.10
},
"GBP": {
"bid": 51.22,
"ask": 51.27
}
},
"date": "2024-01-15T14:30:00Z",
"unit": "gram"
}
Legacy API Quick-Start
Important Legacy Information
- • LondonFixes / JLondonFixes do NOT return official LBMA London fixes. These are our internal indicative index values.
- • We recommend using MarketPrices / JMarketPrices for clearer naming (same proprietary index, better labeling).
- • Historical host
https://xml.dcgcns.org
remains available for pre-2025 clients. - • Existing paths and actions are preserved; same query pattern
?key=...&action=...
Reminder: All legacy data carries the same legal disclaimers regarding accuracy, trading suitability, and user responsibility outlined in the "Read Before You Integrate" section.
Code Examples
Complete working examples for accessing our API across multiple programming languages. All examples use query-string authentication and include proper error handling.
V2 — GSPPJ (All metals, ounce, JSON)
curl -X GET "https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSPPJ" \
-H "Accept: application/json" \
-w "HTTP %{http_code}\n"
const response = await fetch("https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSPPJ");
if (response.ok) {
const data = await response.json();
console.log("Gold USD Ask:", data.gold.USD.ask);
console.log("Silver USD Ask:", data.silver.USD.ask);
console.log("Platinum USD Ask:", data.platinum.USD.ask);
console.log("Palladium USD Ask:", data.palladium.USD.ask);
} else {
console.error("Error:", response.status, response.statusText);
}
import requests
response = requests.get("https://freegoldprice.org/api/v2", params={
"key": "YOUR_API_KEY",
"action": "GSPPJ"
})
if response.status_code == 200:
data = response.json()
print(f"Gold USD Ask: {data['gold']['USD']['ask']}")
print(f"Silver USD Ask: {data['silver']['USD']['ask']}")
print(f"Platinum USD Ask: {data['platinum']['USD']['ask']}")
print(f"Palladium USD Ask: {data['palladium']['USD']['ask']}")
else:
print(f"Error: {response.status_code} - {response.text}")
<?php
$url = "https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSPPJ";
$context = stream_context_create([
'http' => [
'timeout' => 30,
'user_agent' => 'YourApp/1.0'
]
]);
$response = file_get_contents($url, false, $context);
if ($response !== false) {
$data = json_decode($response, true);
if (json_last_error() === JSON_ERROR_NONE) {
echo "Gold USD Ask: " . $data["gold"]["USD"]["ask"] . "\n";
echo "Silver USD Ask: " . $data["silver"]["USD"]["ask"] . "\n";
echo "Platinum USD Ask: " . $data["platinum"]["USD"]["ask"] . "\n";
echo "Palladium USD Ask: " . $data["palladium"]["USD"]["ask"] . "\n";
} else {
echo "Error: Invalid JSON response\n";
}
} else {
echo "Error: Failed to fetch data\n";
}
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
public class Program
{
public static async Task Main()
{
using var client = new HttpClient();
var response = await client.GetAsync("https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSPPJ");
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
var data = JObject.Parse(json);
Console.WriteLine($"Gold USD Ask: {data["gold"]["USD"]["ask"]}");
Console.WriteLine($"Silver USD Ask: {data["silver"]["USD"]["ask"]}");
Console.WriteLine($"Platinum USD Ask: {data["platinum"]["USD"]["ask"]}");
Console.WriteLine($"Palladium USD Ask: {data["palladium"]["USD"]["ask"]}");
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class FreeGoldPriceAPI {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSPPJ"))
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
JsonObject data = JsonParser.parseString(response.body()).getAsJsonObject();
System.out.println("Gold USD Ask: " + data.getAsJsonObject("gold").getAsJsonObject("USD").get("ask"));
System.out.println("Silver USD Ask: " + data.getAsJsonObject("silver").getAsJsonObject("USD").get("ask"));
} else {
System.out.println("Error: " + response.statusCode());
}
}
}
require 'net/http'
require 'json'
uri = URI('https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSPPJ')
response = Net::HTTP.get_response(uri)
if response.code == '200'
data = JSON.parse(response.body)
puts "Gold USD Ask: #{data['gold']['USD']['ask']}"
puts "Silver USD Ask: #{data['silver']['USD']['ask']}"
puts "Platinum USD Ask: #{data['platinum']['USD']['ask']}"
puts "Palladium USD Ask: #{data['palladium']['USD']['ask']}"
else
puts "Error: #{response.code} - #{response.message}"
end
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
type MetalPrice struct {
Ask float64 `json:"ask"`
Bid float64 `json:"bid"`
}
type Currency map[string]MetalPrice
type MetalData map[string]Currency
type Response struct {
Gold MetalData `json:"gold"`
Silver MetalData `json:"silver"`
Platinum MetalData `json:"platinum"`
Palladium MetalData `json:"palladium"`
}
func main() {
resp, err := http.Get("https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSPPJ")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
body, _ := io.ReadAll(resp.Body)
var data Response
json.Unmarshal(body, &data)
fmt.Printf("Gold USD Ask: %.2f\n", data.Gold["USD"].Ask)
fmt.Printf("Silver USD Ask: %.2f\n", data.Silver["USD"].Ask)
fmt.Printf("Platinum USD Ask: %.2f\n", data.Platinum["USD"].Ask)
fmt.Printf("Palladium USD Ask: %.2f\n", data.Palladium["USD"].Ask)
} else {
fmt.Printf("Error: %d\n", resp.StatusCode)
}
}
V2 — GSJM (Gold & Silver, gram, JSON)
curl -X GET "https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSJM" \
-H "Accept: application/json"
const response = await fetch("https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSJM");
if (response.ok) {
const data = await response.json();
console.log("Gold USD Ask (per gram):", data.gold.USD.ask);
console.log("Silver USD Ask (per gram):", data.silver.USD.ask);
} else {
console.error("Error:", response.status);
}
import requests
response = requests.get("https://freegoldprice.org/api/v2", params={
"key": "YOUR_API_KEY",
"action": "GSJM"
})
if response.status_code == 200:
data = response.json()
print(f"Gold USD Ask (per gram): {data['gold']['USD']['ask']}")
print(f"Silver USD Ask (per gram): {data['silver']['USD']['ask']}")
else:
print(f"Error: {response.status_code}")
<?php
$url = "https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSJM";
$context = stream_context_create([
'http' => [
'timeout' => 30,
'user_agent' => 'YourApp/1.0'
]
]);
$response = file_get_contents($url, false, $context);
if ($response !== false) {
$data = json_decode($response, true);
if (json_last_error() === JSON_ERROR_NONE) {
echo "Gold USD Ask (per gram): " . $data["gold"]["USD"]["ask"] . "\n";
echo "Silver USD Ask (per gram): " . $data["silver"]["USD"]["ask"] . "\n";
} else {
echo "Error: Invalid JSON response\n";
}
} else {
echo "Error: Failed to fetch data\n";
}
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
public class Program
{
public static async Task Main()
{
using var client = new HttpClient();
var response = await client.GetAsync("https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSJM");
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
var data = JObject.Parse(json);
Console.WriteLine($"Gold USD Ask (per gram): {data["gold"]["USD"]["ask"]}");
Console.WriteLine($"Silver USD Ask (per gram): {data["silver"]["USD"]["ask"]}");
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class FreeGoldPriceAPI {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSJM"))
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
JsonObject data = JsonParser.parseString(response.body()).getAsJsonObject();
System.out.println("Gold USD Ask (per gram): " + data.getAsJsonObject("gold").getAsJsonObject("USD").get("ask"));
System.out.println("Silver USD Ask (per gram): " + data.getAsJsonObject("silver").getAsJsonObject("USD").get("ask"));
} else {
System.out.println("Error: " + response.statusCode());
}
}
}
require 'net/http'
require 'json'
uri = URI('https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSJM')
response = Net::HTTP.get_response(uri)
if response.code == '200'
data = JSON.parse(response.body)
puts "Gold USD Ask (per gram): #{data['gold']['USD']['ask']}"
puts "Silver USD Ask (per gram): #{data['silver']['USD']['ask']}"
else
puts "Error: #{response.code}"
end
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
type MetalPrice struct {
Ask float64 `json:"ask"`
Bid float64 `json:"bid"`
}
type Response struct {
Gold map[string]MetalPrice `json:"gold"`
Silver map[string]MetalPrice `json:"silver"`
}
func main() {
resp, err := http.Get("https://freegoldprice.org/api/v2?key=YOUR_API_KEY&action=GSJM")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
body, _ := io.ReadAll(resp.Body)
var data Response
json.Unmarshal(body, &data)
fmt.Printf("Gold USD Ask (per gram): %.4f\n", data.Gold["USD"].Ask)
fmt.Printf("Silver USD Ask (per gram): %.4f\n", data.Silver["USD"].Ask)
} else {
fmt.Printf("Error: %d\n", resp.StatusCode)
}
}
V1 — GoldJBA (per gram, JSON, bid & ask)
curl -X GET "https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldJBA" \
-H "Accept: application/json"
const response = await fetch("https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldJBA");
if (response.ok) {
const data = await response.json();
console.log("Gold USD Bid (per gram):", data.gold.USD.bid);
console.log("Gold USD Ask (per gram):", data.gold.USD.ask);
} else {
console.error("Error:", response.status);
}
import requests
response = requests.get("https://freegoldprice.org/api/v1", params={
"key": "YOUR_API_KEY",
"action": "GoldJBA"
})
if response.status_code == 200:
data = response.json()
print(f"Gold USD Bid (per gram): {data['gold']['USD']['bid']}")
print(f"Gold USD Ask (per gram): {data['gold']['USD']['ask']}")
else:
print(f"Error: {response.status_code}")
<?php
$url = "https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldJBA";
$context = stream_context_create([
'http' => [
'timeout' => 30,
'user_agent' => 'YourApp/1.0'
]
]);
$response = file_get_contents($url, false, $context);
if ($response !== false) {
$data = json_decode($response, true);
if (json_last_error() === JSON_ERROR_NONE) {
echo "Gold USD Bid (per gram): " . $data["gold"]["USD"]["bid"] . "\n";
echo "Gold USD Ask (per gram): " . $data["gold"]["USD"]["ask"] . "\n";
} else {
echo "Error: Invalid JSON response\n";
}
} else {
echo "Error: Failed to fetch data\n";
}
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
public class Program
{
public static async Task Main()
{
using var client = new HttpClient();
var response = await client.GetAsync("https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldJBA");
if (response.IsSuccessStatusCode)
{
var json = await response.Content.ReadAsStringAsync();
var data = JObject.Parse(json);
Console.WriteLine($"Gold USD Bid (per gram): {data["gold"]["USD"]["bid"]}");
Console.WriteLine($"Gold USD Ask (per gram): {data["gold"]["USD"]["ask"]}");
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
public class FreeGoldPriceAPI {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldJBA"))
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
JsonObject data = JsonParser.parseString(response.body()).getAsJsonObject();
System.out.println("Gold USD Bid (per gram): " + data.getAsJsonObject("gold").getAsJsonObject("USD").get("bid"));
System.out.println("Gold USD Ask (per gram): " + data.getAsJsonObject("gold").getAsJsonObject("USD").get("ask"));
} else {
System.out.println("Error: " + response.statusCode());
}
}
}
require 'net/http'
require 'json'
uri = URI('https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldJBA')
response = Net::HTTP.get_response(uri)
if response.code == '200'
data = JSON.parse(response.body)
puts "Gold USD Bid (per gram): #{data['gold']['USD']['bid']}"
puts "Gold USD Ask (per gram): #{data['gold']['USD']['ask']}"
else
puts "Error: #{response.code}"
end
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
type MetalPrice struct {
Ask float64 `json:"ask"`
Bid float64 `json:"bid"`
}
type Response struct {
Gold map[string]MetalPrice `json:"gold"`
}
func main() {
resp, err := http.Get("https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldJBA")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
body, _ := io.ReadAll(resp.Body)
var data Response
json.Unmarshal(body, &data)
fmt.Printf("Gold USD Bid (per gram): %.4f\n", data.Gold["USD"].Bid)
fmt.Printf("Gold USD Ask (per gram): %.4f\n", data.Gold["USD"].Ask)
} else {
fmt.Printf("Error: %d\n", resp.StatusCode)
}
}
V1 — GoldBAOE (per ounce, XML, bid & ask)
curl -X GET "https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldBAOE" \
-H "Accept: application/xml"
const response = await fetch("https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldBAOE");
if (response.ok) {
const xmlText = await response.text();
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(xmlText, "text/xml");
const usdBid = xmlDoc.querySelector("gold USD bid").textContent;
const usdAsk = xmlDoc.querySelector("gold USD ask").textContent;
console.log("Gold USD Bid (per ounce):", usdBid);
console.log("Gold USD Ask (per ounce):", usdAsk);
} else {
console.error("Error:", response.status);
}
import requests
import xml.etree.ElementTree as ET
response = requests.get("https://freegoldprice.org/api/v1", params={
"key": "YOUR_API_KEY",
"action": "GoldBAOE"
})
if response.status_code == 200:
root = ET.fromstring(response.text)
usd_bid = root.find(".//gold/USD/bid").text
usd_ask = root.find(".//gold/USD/ask").text
print(f"Gold USD Bid (per ounce): {usd_bid}")
print(f"Gold USD Ask (per ounce): {usd_ask}")
else:
print(f"Error: {response.status_code}")
<?php
$url = "https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldBAOE";
$context = stream_context_create([
'http' => [
'timeout' => 30,
'user_agent' => 'YourApp/1.0'
]
]);
$response = file_get_contents($url, false, $context);
if ($response !== false) {
$xml = simplexml_load_string($response);
if ($xml !== false) {
$usdBid = (string)$xml->gold->USD->bid;
$usdAsk = (string)$xml->gold->USD->ask;
echo "Gold USD Bid (per ounce): " . $usdBid . "\n";
echo "Gold USD Ask (per ounce): " . $usdAsk . "\n";
} else {
echo "Error: Invalid XML response\n";
}
} else {
echo "Error: Failed to fetch data\n";
}
?>
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Xml;
public class Program
{
public static async Task Main()
{
using var client = new HttpClient();
var response = await client.GetAsync("https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldBAOE");
if (response.IsSuccessStatusCode)
{
var xmlContent = await response.Content.ReadAsStringAsync();
var xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlContent);
var usdBid = xmlDoc.SelectSingleNode("//gold/USD/bid")?.InnerText;
var usdAsk = xmlDoc.SelectSingleNode("//gold/USD/ask")?.InnerText;
Console.WriteLine($"Gold USD Bid (per ounce): {usdBid}");
Console.WriteLine($"Gold USD Ask (per ounce): {usdAsk}");
}
else
{
Console.WriteLine($"Error: {response.StatusCode}");
}
}
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import java.io.ByteArrayInputStream;
public class FreeGoldPriceAPI {
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldBAOE"))
.GET()
.build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new ByteArrayInputStream(response.body().getBytes()));
String usdBid = doc.getElementsByTagName("bid").item(0).getTextContent();
String usdAsk = doc.getElementsByTagName("ask").item(0).getTextContent();
System.out.println("Gold USD Bid (per ounce): " + usdBid);
System.out.println("Gold USD Ask (per ounce): " + usdAsk);
} else {
System.out.println("Error: " + response.statusCode());
}
}
}
require 'net/http'
require 'rexml/document'
uri = URI('https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldBAOE')
response = Net::HTTP.get_response(uri)
if response.code == '200'
doc = REXML::Document.new(response.body)
usd_bid = doc.elements['//gold/USD/bid'].text
usd_ask = doc.elements['//gold/USD/ask'].text
puts "Gold USD Bid (per ounce): #{usd_bid}"
puts "Gold USD Ask (per ounce): #{usd_ask}"
else
puts "Error: #{response.code}"
end
package main
import (
"encoding/xml"
"fmt"
"io"
"net/http"
)
type MetalPrice struct {
Bid float64 `xml:"bid"`
Ask float64 `xml:"ask"`
}
type Response struct {
Gold struct {
USD MetalPrice `xml:"USD"`
} `xml:"gold"`
}
func main() {
resp, err := http.Get("https://freegoldprice.org/api/v1?key=YOUR_API_KEY&action=GoldBAOE")
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
body, _ := io.ReadAll(resp.Body)
var data Response
xml.Unmarshal(body, &data)
fmt.Printf("Gold USD Bid (per ounce): %.2f\n", data.Gold.USD.Bid)
fmt.Printf("Gold USD Ask (per ounce): %.2f\n", data.Gold.USD.Ask)
} else {
fmt.Printf("Error: %d\n", resp.StatusCode)
}
}
💡 Tip: You can swap actions in any example to get different metals, units, or formats.
For example, change GSPPJ
to GSPPX
to get XML instead of JSON.
Supported Currencies
Our API supports 163 global currencies. Here's a sample of available currency codes:
Major Currencies
- USD - US Dollar
- EUR - Euro
- GBP - British Pound
- JPY - Japanese Yen
- CAD - Canadian Dollar
- AUD - Australian Dollar
- CHF - Swiss Franc
- CNY - Chinese Yuan
European
- SEK - Swedish Krona
- NOK - Norwegian Krone
- DKK - Danish Krone
- PLN - Polish Zloty
- CZK - Czech Koruna
- HUF - Hungarian Forint
- RON - Romanian Leu
- BGN - Bulgarian Lev
Asia-Pacific
- KRW - South Korean Won
- INR - Indian Rupee
- SGD - Singapore Dollar
- HKD - Hong Kong Dollar
- TWD - Taiwan Dollar
- THB - Thai Baht
- MYR - Malaysian Ringgit
- PHP - Philippine Peso
Others & Emerging
- BRL - Brazilian Real
- MXN - Mexican Peso
- ZAR - South African Rand
- RUB - Russian Ruble
- TRY - Turkish Lira
- AED - UAE Dirham
- SAR - Saudi Riyal
- ... and many more
Total supported: 163 - This includes major world currencies, emerging market currencies, and regional currencies. The complete list is available in all API responses showing available currency codes.
Price Precision
Ounce Prices
2 decimal places
Example: $2,024.50 USD per ounce
Gram Prices
4 decimal places
Example: $65.0842 USD per gram
These precision levels ensure accurate pricing for both investment-grade transactions and smaller retail purchases.
Technical Specifications
Response Headers
- XML:
text/xml; charset=UTF-8
- JSON:
application/json; charset=UTF-8
- Encoding: UTF-8
- Compression: Gzip supported
Security
- HTTPS: Required, TLS encryption
- Authentication: Query string only
- Headers: Security headers included
- Data Safety: Entity loading disabled
Rate Limiting
- Model: Credit-based system
- Cost: 1 credit per successful request
- Failed requests: No credit charge
- Throttling: Based on credit balance
Data Updates
- Frequency: Every 5-15 minutes
- Caching: 65-minute server cache
- Sources: Multiple market data providers
- Availability: 24/7 operation
Error Codes
All API errors return HTTP status 400 Bad Request with a short descriptive message in the response body.
Message | Description | HTTP Status |
---|---|---|
Invalid key | API key not found or invalid format | 400 |
Invalid action | Action parameter not recognized or unsupported | 400 |
Insufficient hits | Zero credits remaining on your account | 400 |
No data available | No current price data available for request | 400 |
Missing parameters | Required key or action parameter missing from request | 400 |
Error Handling Tip: Always check the HTTP status code first. A status of 200 indicates success, while 400 indicates an error with details in the response body.
Migration V1 → V2
API V2 offers significant efficiency improvements by allowing multiple metals to be retrieved in a single request, reducing the number of API calls and credits required for comprehensive pricing data.
V1 Approach (Legacy)
Multiple separate requests required:
- • Call
GoldJBA
for gold prices (1 credit) - • Call
SilverJBA
for silver prices (1 credit) - • Call
PlatinumJBA
for platinum prices (1 credit) - • Call
PalladiumJBA
for palladium prices (1 credit)
Total: 4 requests, 4 credits
V2 Approach (Recommended)
Single consolidated request:
- • Call
GSPPJM
for all four metals (1 credit) - • Receive gold, silver, platinum, and palladium
- • Complete bid & ask prices included
- • Same precision and currency support
Total: 1 request, 1 credit
Migration Benefits
- • 75% fewer credits for complete precious metals data
- • Reduced latency with fewer HTTP requests
- • Atomic data consistency - all prices from same timestamp
- • Simplified code with consolidated responses
- • Future-proof with continued development focus