Developers

Integrate a live, reliable price layer into your system through one API.

One clear API, request the price whenever you want, or receive it the instant it changes over the live stream, and every price arrives with its explicit state and within a stable data contract.

Start in three steps

01

Get an access token

Tokens are issued after a conversation that understands your need, not by self-signup, governed by scopes and rate limits. You get a token with only the permissions you need.

02

Request the price

A single call to the API returns the latest price for the metals in the currency you choose within a stable contract, with the gold karats and the state of each price.

03

Read its state first

Before you build a decision on the price, check the state attached to it, live, market closed, or stale. That way you never adopt a dead price.

Authentication and limits

Every request carries an access token in the Authorization header. Some endpoints require an additional permission scope.

Access token

Sent with every request in the Authorization header as Bearer TOKEN. Tokens are issued manually after a conversation.

Permission scopes

Each token carries its own scopes, base prices are always available, while daily statistics and live streaming each need a dedicated scope.

Rate limit

Your token is allowed more than one request per second, and every successful response carries headers telling you your limit and how much of the current window remains.

The scopes

default Live prices with their state and karats, plus metals, currencies, status and your token details. Available to every token.
daily_stats Today statistics, open, high, low, close and change, plus the /daily-stats endpoint.
instant_change The instant rate of change for each metal, attached to its price inside /prices.
live_stream Authentication for the real-time streaming channel over WebSocket.

Headers and rate limit

Read these headers to pace your requests without overrunning, and build your retry logic with confidence.

X-RateLimit-Limit The maximum requests your token is allowed in the window.
X-RateLimit-Remaining What remains for you in the current window.
X-RateLimit-Window The length of the window, its value is one second.
Retry-After Appears with a 429 when you overrun, the number of seconds before you retry.

Test mode

Try the response shape before your tokens are issued. Send the literal token test and the response arrives in its full shape with all numeric values zeroed, so you build your integration on the real structure without live data.

Endpoints

Base URL
https://barqmetal.com/api/v1

Every request needs an access token. Endpoints marked with a scope require an additional permission.

GET /prices Live prices for the metals, in the requested currency, with state and karats. default
GET /daily-stats Today statistics for each metal. daily_stats
GET /metals The list of available metals and their symbols. default
GET /currencies The supported currencies and their exchange rates. default
GET /status The current service status and last update. default
GET /token Your token details, its scopes, limits and usage. default
POST /websocket/auth Authentication for the real-time streaming channel. live_stream
GET /websocket/info Connection details for the live stream and its event shape. default

Example response

A fixed shape for every response. Any change is coordinated with consuming systems in advance, so your integration never breaks suddenly.

This is a base response. With the instant_change scope an instant-change field is added to each metal, and with the daily_stats scope a today-statistics field. See the endpoint reference below for every field by type.

Per-gram prices arrive with four decimals, per-ounce and karat prices with two. The values in the example are illustrative, so read the precision from the field reference, not from the example.

When you request a single metal via symbol, the data field returns a single object, not an array. Without symbol it returns an array of every metal.

GET /prices response (illustrative values)
{
  "success": true,
  "currency": "SAR",
  "request_time": "2026-08-14T11:42:05.417+03:00",
  "system": { "is_running": true, "last_update": "2026-08-14T11:42:05.417+03:00", "server_time": "2026-08-14T11:42:05.417+03:00" },
  "data": [
    {
      "metal": { "id": 1, "symbol": "XAU", "name_ar": "الذهب", "name_en": "Gold" },
      "state": "live",
      "prices": {
        "buy_per_ounce": 12545.60,
        "sell_per_ounce": 12551.20,
        "buy_per_gram": 403.20,
        "sell_per_gram": 403.50,
        "fetched_at": "2026-08-14T11:42:05.417+03:00",
        "last_success_at": "2026-08-14T11:42:07.912+03:00",
        "price_changed_at": "2026-08-14T11:40:11.005+03:00"
      },
      "karats": {
        "24": { "sell_per_gram": 403.50 },
        "22": { "sell_per_gram": 369.88 },
        "21": { "sell_per_gram": 353.06 },
        "18": { "sell_per_gram": 302.63 }
      }
    }
  ]
}

Endpoint reference

Each endpoint with its params and response fields by type and meaning, so you integrate against this page alone, no conversation needed.

GET /prices Live prices for the metals with state and karats.
Parameters
ParamTypeMeaning
symbol string A single metal symbol to filter the result, e.g. XAU. Letters and digits up to ten. With no value all metals are returned.
currency string The currency code, letters up to ten. Defaults to USD, and an unsupported currency returns in USD.
include_daily_stats 0 or 1 Include today statistics for each metal. Enabled unless you send 0.
Response fields
FieldTypeMeaning
currency string The resolved currency for this response.
request_time string The moment the request was processed, ISO8601.
system.is_running bool Whether the feed is live now.
system.last_update string The moment of the feed last update, ISO8601 with millisecond precision.
system.server_time string The live system clock, advancing every second even when the source dries up, ISO8601 with millisecond precision.
data[].metal object The metal, its id, symbol and name in Arabic and English.
data[].state string The price state, one of live, market_closed or stale.
data[].prices.buy_per_ounce number Buy price per ounce, two decimals.
data[].prices.sell_per_ounce number Sell price per ounce, two decimals.
data[].prices.buy_per_gram number Buy price per gram, four decimals.
data[].prices.sell_per_gram number Sell price per gram, four decimals.
data[].prices.fetched_at string The moment of the last accepted fetch for this price (the freshness gate), ISO8601 with millisecond precision.
data[].prices.last_success_at string The moment of the last successful fetch even when the value was rejected, ISO8601 with millisecond precision.
data[].prices.price_changed_at string The moment of the last real price change, ISO8601 with millisecond precision, null before the first change.
data[].karats object Per-karat sell price per gram for 24, 22, 21 and 18, two decimals, gold only.
data[].instant_change object The instant change, buy and sell amount and percent with an up, down or stable direction.instant_change
data[].daily_stats object Today statistics for this metal, open, high, low, close, change, range and update count.daily_stats
GET /daily-stats Today statistics for each metal.
Parameters
ParamTypeMeaning
symbol string Filter by a single metal, e.g. XAU.
currency string The currency code, defaults to USD.
Response fields
FieldTypeMeaning
currency string The resolved currency.
date string The statistics day, year-month-day.
data[].metal object The metal, its id, symbol and Arabic name.
data[].sell object The sell statistics, open, high, low, close, change and percent.
data[].buy object The buy statistics, with the same fields.
data[].direction string The day direction, up, down or stable.
data[].range number The day range, the difference between high and low.
data[].update_count int The number of updates recorded today.
GET /metals The available metals and their symbols.
Parameters
No parameters, your access token is enough.
Response fields
FieldTypeMeaning
count int The number of metals.
data[].symbol string The metal symbol, e.g. XAU.
data[].name_ar string The Arabic name.
data[].name_en string The English name.
data[].gram_per_base_unit number Grams in the base measurement unit.
GET /currencies The supported currencies and their exchange rates.
Parameters
No parameters, your access token is enough.
Response fields
FieldTypeMeaning
base_currency string The base currency, always the US Dollar.
data[].code string The currency code, e.g. SAR.
data[].symbol string The display symbol.
data[].exchange_rate number How many units of this currency equal one US Dollar.
data[].is_default bool Whether it is the default currency.
GET /status The current service status and last update.
Parameters
No parameters, your access token is enough.
Response fields
FieldTypeMeaning
data.is_running bool Whether the feed is live now.
data.last_update string The moment of the last update.
GET /token Your token details, its scopes, limits and usage.
Parameters
No parameters, your access token is enough.
Response fields
FieldTypeMeaning
data.abilities array The scopes, each with its name and whether it is granted to your token.
data.rate_limit object Your limit, requests per second and its label.
data.usage object Your usage, total requests and last use.
data.expires_at string The token expiry if any.
GET /websocket/info Connection details for the live stream and its event shape.
Parameters
No parameters, your access token is enough.
Response fields
FieldTypeMeaning
data.connection object The server details, host, port, key and scheme.
data.auth object The auth endpoint, its method, headers and params.
data.channels array The channels, their events and the event data shape.
POST /websocket/auth Authenticate the private live-stream channel.
Parameters
ParamTypeMeaning
socket_id string The connection id, your stream client gives it to you automatically. Required.
channel_name string The private channel name to subscribe to. Required.
Response fields
FieldTypeMeaning
auth string The auth signature your stream client passes to the channel.

Errors and codes

Every error returns one fixed shape, a status code and an object explaining the cause, so your system builds its retry logic with confidence.

The error object shape
{
  "success": false,
  "error": "...",
  "status": 404,
  "request_time": "2026-08-14T11:42:05+03:00"
}
401 The access token is missing or invalid.
403 The token is suspended or expired, lacks the required scope, or the IP is not allowed.
404 The requested metal is unknown, or no metals are active.
422 The request params are invalid, with the details in the errors field.
429 You exceeded the allowed request rate, wait then retry.
500 A transient internal error, retry shortly.

An errors field is attached with a 422 only, carrying the details of the invalid param. And with a 429 you may receive a Retry-After header telling you when to retry.

Live streaming

Instead of repeated polling, subscribe once and every update reaches you at the same instant. Two steps, authenticate the channel, then connect.

  1. 01 Authenticate the channelSend a POST to /websocket/auth with a token carrying the live_stream scope, and you receive the temporary connection details.
  2. 02 Connect and receiveOpen the connection using those details, and every price update reaches you the moment it happens, in the same shape with its state attached.

Code samples

Copy and start. Replace TOKEN with your access token.

cURL
curl -H "Authorization: Bearer TOKEN" \
  "https://barqmetal.com/api/v1/prices?currency=SAR"

Try it

Choose an endpoint and press Run for a live response straight from the API, alongside a ready cURL command and JavaScript code to copy.

cURL command
JavaScript (fetch)
Live response

A real live call. With no token the demo mode is used, the same response shape with zeroed values. With your token you get the real values.

Developer FAQ

How do I connect a live gold price to my app or site?
Request an access token, then call the Barq price API to get the latest gold and silver price in the currency you choose, or subscribe to the live stream to receive updates the instant they happen. Every price arrives with its explicit state, so your system knows when to trust it.
What gold price API does Barq offer?
A documented API that returns the live gold and silver price within a stable data contract, with the per-karat prices (24, 22, 21, 18) in Saudi Riyal and US Dollar, and a live stream over WebSocket for anyone who wants instant updates.
Which currency does Barq return the gold price in?
The Saudi Riyal and the US Dollar are supported today, and you request the price in either, with the per-gram gold price computed for each karat and ready for direct display. The currencies endpoint returns the active list at request time, and more currencies are added from the admin panel. Barq is built for the Gulf market, Arabic-first, from the ground up.
How delayed is the price, and is it really live?
The price refreshes more than once a second on the live stream, and reaches your system the instant it happens with no repeated polling. An API read returns the latest adopted price on demand, carrying its update time and its state.
What happens to my price if a source fails at Barq?
The price reaching your API does not stop, Barq switches automatically to the next best source. And if the sources drop during trading, the price reaches you labelled "stale" instead of a misleading number, so you never build a decision on a dead price.

Your access token starts with a conversation.

The documentation is complete in front of you, the endpoints with their params, fields and errors. No self-signup today, tell us about your system and your need and we will arrange the right access with the scopes you require.

Contact us We walk with you step by step until the integration works.