Skip to main content

Assets

Safello deals with two types of assets - normal (fiat) currencies such as Swedish Kronor (SEK) or Euros (EUR) and cryptocurrencies such as Bitcoin (BTC) or Ethereum (ETH).

Symbols​

The static representation of the various currencies can be retrieved from endpoint paths under /v2/symbols/.

tip

The currencies (of both types) supported by Safello change infrequently and are therefore good candidates for client-side cacheing over the duration of a customer session

The set of Fiat currencies that Safello supports (or has supported) can be obtained by issuing a GET request to the /v2/symbols/fiat endpoint.

Retrieving fiat currency list example
curl \
--silent \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header 'source-ip-address: 127.0.0.1' \
--header 'source-user-agent: curl' \
--request GET \
--location 'https://api.s4f3.io/v2/symbols/fiat'
[
{
"currency": "SEK",
"minorAmountDecimals": 2,
"displayName": "Kronor",
"status": "active"
}
]

The set of Cryptocurrencies that Safello supports (or has supported) can be obtained by issuing a GET request to the /v2/symbols/crypto endpoint.

Retrieving crypto currency price example
curl \
--silent \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header 'source-ip-address: 127.0.0.1' \
--header 'source-user-agent: curl' \
--request GET \
--location 'https://api.s4f3.io/v2/symbols/crypto'

Where a currency's status value is deprecated or where the availableActions list contains no entries the currency can not be bought or sold. For example in the current output shown the Ripple (XRP) currency is not currently supported by Safello.

[
{
"currency": "BTC",
"minorAmountDecimals": 8,
"displayName": "Bitcoin",
"status": "active",
"availableActions": [
"buy",
"sell"
]
},
{
"currency": "DOT",
"minorAmountDecimals": 8,
"displayName": "Polkadot",
"status": "active",
"availableActions": [
"buy",
"sell"
]
},
{
"currency": "MATIC",
"minorAmountDecimals": 8,
"displayName": "Polygon",
"status": "active",
"availableActions": [
"buy",
"sell"
]
},
{
"currency": "XRP",
"minorAmountDecimals": 8,
"displayName": "Ripple",
"status": "deprecated",
"availableActions": []
},
{
"currency": "ETH",
"minorAmountDecimals": 8,
"displayName": "Ethereum",
"status": "active",
"availableActions": [
"buy",
"sell"
]
}
]

Prices and Price History​

The current price and the price histories of the cryptocurrencies can be retrieved for presentation to the retail customers. Naturally these data are not customer-specific.

For all price related queries the cryptocurrencies and/or fiat currencies requested must be from amongst those returned by the respective symbols endpoints and must have status field values of active.

To retrieve the current fiat price for a cryptocurrency, make a GET request to the /v2/prices/rates/{crypto} endpoint supplying a path parameter to specify the cryptocurrency of interest and a query parameter of fiat to specify the fiat currency in which the price for the cryptocurrency should be quoted.

Requesting the current price example

In this example the price of Bitcoin (BTC) in Swedish Kronor (SEK) is requested:

curl \
--silent \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header 'source-ip-address: 127.0.0.1' \
--header 'source-user-agent: curl' \
--request GET \
--location 'https://api.s4f3.io/v2/prices/rates/BTC?fiat=SEK'
{
"ask": "298111.2134",
"baseAsk": "298111.2134",
"baseBid": "299898.0938",
"bid": "299898.0938",
"cryptoCurrency": "BTC",
"currency": "SEK"
}

To retrieve the price history for a cryptocurrency, make a GET request to the /v2/prices/history endpoint supplying query parameters of crypto to specify the cryptocurrency of interest and interval to specify the time period over which the results will be returned. Price history is always returned in Swedish Kronor (SEK).

Valid interval values are:

ValueDatum for every...Meaning
DAILY10 MinutesValues since the same timestamp on the preceding calendar date
WEEKLY10 MinutesValues since the same timestamp on the same day of the preceding calendar week.
MONTHLY1 HourValues since the same timestamp on the same day of the preceding calendar month.
QUARTERLY1 HourValues since the same timestamp on the same day of the calendar month three months earlier.
HALF_YEARLY12 HoursValues since the same timestamp on the same day of the calendar month six months earlier.
YEARLY1 DayValues since the same timestamp on the same calendar day of the preceding calendar year.
YTD1 DayValues since midnight on 1st January of the current calendar year.
MAX1 DayAll values known to date

Where the corresponding day would be invalid (e.g. an interval of MONTHLY is selected on the 30th March, or yearly is selected in a leap year on 29th February), then the start of the range will be the last valid calendar date of the calendar month in question.

warning

Under some circumstances there may be no trade data for one or more of the datapoints (this is especially true in our test environment). You should therefore ensure that the timestamps are appropriately plotted and not assumed to be chronologically contiguous.

Requesting price history for Bitcoin (BTC) example

This example query will return the price history data for the past 24 hours with an entry (where present) for every 10 minutes.

curl \
--silent \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header 'source-ip-address: 127.0.0.1' \
--header 'source-user-agent: curl' \
--request GET \
--location 'https://api.s4f3.io/v2/prices/history?crypto=BTC&interval=DAILY'
[
{ "timestamp": 1652102400000, "price": "96007.96" },
{ "timestamp": 1652179200000, "price": "104884.10" }
]

The timestamps in the returned data are in milliseconds since the Unix epoch. This contrasts with the authentication timestamps that are in seconds since the Unix epoch. In the given example they correspond to the following human readable timestamps for local-time in Stockholm:

Epoch TimestampHuman readable timestamp CEST
1652102400000Monday, 9 May 2022 13:20:00
1652179200000Tuesday, 10 May 2022 10:40:00