Currencies
Use these methods to manage currencies in the Back Office.
GET[host]/api/v2/currencies |
|
GET[host]/api/v2/currencies{currencyId} |
|
POST[host]/api/v2/currencies |
|
PUT[host]/api/v2/currencies{currencyId} PATCH[host]/api/v2/currencies{currencyId} |
|
DELETE[host]/api/v2/currencies/{currencyId} |
Get a list of currencies
Use this method to obtain a list of the currencies available in the Back Office.
To obtain detailed information about a specific currency, use a separate method to get currency details.
Request
Header parameters:
Authorization: Bearer <access_token>
Query parameters:
The following filter parameters are available for this method:
- alphabeticCode
The alphabetic currency code (such as
BTC
).- numericCode
The numeric code that is used as a unique currency identifier.
- enabled
If
true
, a currency can be used for financial operations; otherwise,false
.
The following sorting parameter is available for this method:
- createTime
The date and time when a currency was added to the Back Office.
Refer to the Query parameters section of the API Overview for details on applying filter and sorting parameters.
GET[host]/api/v2/currencies
curl --location -g --request GET 'https://host.name/api/v2/currencies?limit=10&offset=0&sort_order=desc&sort_by=createTime&filter[alphabeticCode]=BTC&filter[numericCode]=1000&filter[enabled]=true' \
--header 'Authorization: Bearer <token>'
Response
A response includes an array of Currency objects providing information about the currencies matching the request parameters.
Get currency details
Use this method to obtain detailed information about a specified currency.
To obtain a list of available currencies, use a separate method to get a list of currencies.
Request
Header parameters:
Authorization: Bearer <access_token>
Path parameters:
- currencyId required
The numeric code that is used as a unique currency identifier.
GET[host]/api/v2/currencies/{currencyId}
curl --location --request GET 'https://host.name/api/v2/currencies/840' \
--header 'Authorization: Bearer <token>'
Response
A response includes a Currency object providing information about the specified currency.
Add a currency
Use this method to add a currency to the Back Office.
Request
Header parameters:
Authorization: Bearer <access_token>
Body:
Specify the following parameters for a currency:
- alphabeticCode string required
The alphabetic currency code (such as
BTC
).- numericCode integer required
The numeric code that is used as a unique currency identifier.
- name string required
The currency name (such as
Bitcoin
).- minorUnit integer required
The number of decimal places displayed when representing amounts in a currency.
- markupBuy number
The buy commission markup, as a percentage.
- markupSell number
The sell commission markup, as a percentage.
- blockExplorer string
Applicable only for cryptocurrencies.
The cryptocurrency block explorer.
- resources array
An array of resource objects, specifying localized strings for user interface pages displayed to a client.
POST[host]/api/v2/currencies
curl --location --request POST 'https://host.name.b2broker.org/api/v2/currencies' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"alphabeticCode": "BTC",
"numericCode": 1000,
"name": "Bitcoin",
"minorUnit": 8,
"markupBuy": 0,
"markupSell": 55.55,
"blockExplorer": "https://live.blockcypher.com/btc/tx/{address}",
"resources": [
{
"key": "caption",
"locale": "ja_JP",
"value": "ビットコイン"
}
]
}'
Response
A response includes a Currency object providing information about the added currency.
Update a currency
Use this method to update the data related to a specified currency.
Note
Instead of the method described below, you can use a similar method that uses the HTTP verb PATCH.
Request
Header parameters:
Authorization: Bearer <access_token>
Path parameters:
- currencyId required
The numeric code that is used as a unique currency identifier.
Body:
The following field values can be updated for a currency:
- name string
The currency name (such as
Bitcoin
).- minorUnit integer
The number of decimal places displayed when representing amounts in a currency.
- markupBuy number
The buy commission markup, as a percentage.
- markupSell number
The sell commission markup, as a percentage.
- blockExplorer string
Applicable only for cryptocurrencies.
The cryptocurrency block explorer.
- resources array
An array of resource objects, specifying localized strings for user interface pages displayed to a client.
PUT[host]/api/v2/currencies/{currencyId}
curl --location --request PUT 'https://host.name/api/v2/currencies/840' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"name": "Us Dollar",
"minorUnit": 2,
"markupBuy": 55.55,
"markupSell": 55.55,
"resources": [
{
"key": "caption",
"locale": "ja_JP",
"value": "米ドル"
}
]
}'
Response
A response includes a Currency object providing information about the currency that was updated.
Delete a currency
Use this method to delete a specified currency.
Request
Header parameters:
Authorization: Bearer <access_token>
Path parameters:
- currencyId required
The numeric code that is used as a unique currency identifier.
DELETE[host]/api/v2/currencies/{currencyId}
curl --location --request DELETE 'https://host.name/api/v2/currencies/840' \
--header 'Authorization: Bearer <token>'
Response
In case of success, no response body is returned.