Introduction
The APIs represented here are a small subset of the APIs that are actually available and are prone to change quite rapidly.
This document and related APIs are for the consumption of B2B partners of SB Group. SB Group provides the tooling necessary for other businesses to own and operate their own asset backed business. Powered by Gramchain technology, this system provides sufficient transparency into the underlying assets.
Getting Started
We will create the necessary Oauth2 client credentials for your servers to make authenticated calls to our system. Please note that access is subject to KYC and other approval mechanisms.
API flow
For a B2B client we have a simplified flow by which the business client can update the holdings of the end consumer.
Price Feed
The spot price endpoint gives three prices - the spot purchaseNoDisc, the purchase/buy and the sellback/sell price along with an encrypted token representing the quote which is valid for 90 seconds. Do note that the prices are refreshed every 30 seconds. The encrypted token is used to lock in the price for the transaction.
The metal grams and fiat amount are required to be passed in the request to execute the transaction. The fiat amount is the amount of fiat that the customer has agreed to pay for the transaction. The metal grams is the amount of metal that the customer has agreed to buy or sell. The fiat amount is used as the basis for the transaction and is used to calculate the amount of metal grams that the customer will receive or pay.
The metal grams is rounded up if dust exists in the case of sellback and rounded down in the case of purchase. The rounding is done to 8 decimal places.
For purchases:
metal grams = Math.truncate((fiat amount / purchase price) * 100000000) / 100000000
For sellbacks:
metal grams = (fiat amount / sellback price) > Math.Truncate(metal grams * 100000000) / 100000000
? Math.Truncate(metal grams * 100000000 + 1) / 100000000
: Math.Truncate(metal grams * 100000000) / 100000000
PS: Math.truncate is a function that truncates the decimal part of a number and returns the integer part of the number.
Buy - Workflow
We use a quotation based flow, the B2B Server requests a quotation for X amount of Dollars worth of gold grams.
Steps:
- Authenticate with client credentials.
- Call the get spot price and token.
- With the response from step 2 internally request your customer to agree and collect payment.
- Once the customer has locked in the payment, you can call our execute transaction api endpoint with the token, fiat amount and the amount of metal grams.
- The response will contain the transaction id and the amount of metal grams.
Sell - Workflow
The flow is a mirror of the buy api except for the request and response parameters.
Steps:
- Authenticate with client credentials.
- Call the get quotation price.
- With the response from step 2 internally request your customer to agree and confirm the order.
- Once the customer has locked in, you can call our execute transaction api endpoint with the token, fiat amount and the amount of metal grams.
- The response will contain the transaction id and the amount of metal grams.
Trading Hours
The trading hours exclude Singapore public holidays and when market hours are closed:
| Daylight Savings Time | Non Daylight Savings Time (Singapore Time) | |
|---|---|---|
| Monday | Opens 06:00 | Opens 07:00 |
| Tuesday | 05:00 - 06:00 | 06:00 - 07:00 |
| Wednesday | 05:00 - 06:00 | 06:00 - 07:00 |
| Thursday | 05:00 - 06:00 | 06:00 - 07:00 |
| Friday | 05:00 - 06:00 | 06:00 - 07:00 |
| Saturday | Closed after 05:00 | Closed after 06:00 |
| Sunday | Closed | Closed |
Current daylight savings time is from 30 March 2025 to 26 October 2025.
No trades are permitted when the markets are closed. This can be infered from the spot price endpoint with the value of the 'market' flag. The validity period of the encrypted spot token is used to indicate an upcoming market close. The token is always generated with a validity duration of 90 seconds. But prior to market close, spot rate requests within 2 minutes prior to market close will contain tokens with a validity period starting from 2 minutes prior to closing, irrespective of the timing of the request. This means that any token will be valid only upto 30 seconds of market close and no trades are permitted in the 30 seconds prior to market close.
Timeouts and Long living transactions
In the case of timeouts and system failures, the B2B customer can check with our systems via the /api/checkTx/{customerTxId} end point and pass the customer transaction reference id. If there was a transaction created we will send the latest data for that transaction else we will return a 404.
Please note that this api is a TODO.
Notes
Currently we do not make use of any queues to store the quotations created. So in case the quotation is lost. Please recreate a new quote. This process might change in the future and we may make it async depending on the velocity of transactions that we need to manage. But we will maintain backward compatibility.