---
title: "Gold converter API: GET /v1/convert · goldprice.dev"
description: "Convert gold, silver and currencies by ounce, gram or kilogram using goldprice.dev: curl, JavaScript and Python code, a full response example and error codes."
canonical: "https://goldprice.dev/docs/endpoints/convert"
---

> Index of every goldprice.dev page and doc for AI readers: [llms.txt](https://goldprice.dev/llms.txt)

# Convert between metal and currency

GET /v1/convert: convert metal to currency by ounce, gram or kilogram

`GET /v1/convert?from=XAU&to=INR&amount=10&unit=gram` gives the value of 10 grams of gold in rupees. Convert metal to currency or currency to metal using ounces, grams or kilograms. A key is optional. Free and keyless prices are delayed by 15 minutes.

## Make a request

Set `from` and `to` to a metal (XAU, XAG, XPT, XPD) or a currency. The `unit` parameter controls the metal unit, with troy ounces as the default.

```bash
curl "https://api.goldprice.dev/v1/convert?from=XAU&to=INR&amount=10&unit=gram" \
  -H "Authorization: Bearer $GOLDPRICE_API_KEY"
```

```javascript
const res = await fetch("https://api.goldprice.dev/v1/convert?from=XAU&to=INR&amount=10&unit=gram", {
  headers: { Authorization: `Bearer ${process.env.GOLDPRICE_API_KEY}` },
})
const data = await res.json()
if (!res.ok) throw new Error(data.error)
```

```python
import os, requests

res = requests.get(
    "https://api.goldprice.dev/v1/convert?from=XAU&to=INR&amount=10&unit=gram",
    headers={"Authorization": f"Bearer {os.environ['GOLDPRICE_API_KEY']}"},
    timeout=10,
)
res.raise_for_status()
data = res.json()
```

## Request parameters

| Name | Location | Required | Description |
| --- | --- | --- | --- |
| `from` | query | Yes | Source metal or currency |
| `to` | query | Yes | Target metal or currency |
| `amount` | query | No (1) | Amount for conversion |
| `unit` | query | No (oz) | Metal unit: oz, gram or kg |

## Read the response

This example response was recorded without a key on 19 Oct 2026. `rate` retains full precision, while `result` is rounded.

```json title="Response example (19 Oct 2026)"
{
  "from": "XAU",
  "to": "INR",
  "amount": "10.0",
  "rate": "12705.74376559729168283849219",
  "result": "127057.44",
  "unit": "gram",
  "timestamp": "2026-10-19T12:45:06.720397Z",
  "delayed_minutes": 15
}
```

| Field | Description |
| --- | --- |
| `from`, `to` | Conversion source and target |
| `amount` | Submitted amount |
| `rate` | Full-precision value of one unit |
| `result` | Rounded conversion result |
| `unit` | Metal unit used |
| `timestamp` | Spot price observation time (UTC) |
| `delayed_minutes` | 15 when the price is 15 minutes behind live (keyless and Free). Absent on paid answers. |

## API errors

| Status | error | Cause |
| --- | --- | --- |
| 400 | `unsupported_unit` | Unit must be oz, gram or kg |
| 429 | `rate_limited` | Keyless IP exceeded 100 requests in the hour |
| 429 | `rate_limit_exceeded` | Minute limit exceeded for the plan, or per IP without a key |
| 429 | `quota_exceeded` | Plan's monthly request quota exceeded |

```json title="Error response example"
{
  "error": "unsupported_unit",
  "message": "Unsupported unit"
}
```

## Request and data limits

Free and keyless prices are delayed by 15 minutes. Without a key, you get 10 requests a minute per IP. A free key includes 5,000 requests a month. Paid plans provide live prices. See [free plan limits](https://goldprice.dev/free-plan-limits) for all plan limits.

## Questions

### How can I convert gold in grams to a currency?

Call /v1/convert?from=XAU&to=INR&amount=10&unit=gram. Read result for the value of 10 grams.

### Can I convert a currency amount to gold?

Yes. Reverse the sides: /v1/convert?from=USD&to=XAU&amount=1000 returns the gold that $1,000 buys, in troy ounces unless you set unit.

### Which units are supported?

oz is the default. You can also use gram or kg. Other units return 400 unsupported_unit.

Source: https://goldprice.dev/docs/endpoints/convert
