Appearance
4swap API
Read info
GET /info
This API will return MTG information about 4swap
Response
json
{
"ts": 1627697766645,
"data": {
// user id of MTG members
"members": [
"a753e0eb-3010-4c4a-a7b2-a7bda4063f62",
"099627f8-4031-42e3-a846-006ee598c56e",
"aefbfd62-727d-4424-89db-ae41f75d2e04",
"d68ca71f-0e2c-458a-bb9c-1d6c2eed2497",
"e4bc0740-f8fe-418c-ae1b-32d9926f5863"
],
"public_key": "dt351xp3KjNlVCMqBYUeUSF45upCEiReSZAqcjcP/Lc=",
// multisig threshold
"threshold": 3
}
}
TIP
You can save the response to use it later because the MTG information wouldn't change frequently.
Read assets
GET /assets
This API will respond all supported crypto assets.
Response
json
{
"ts": 1627697766503,
"data": {
"assets": [
// {Asset Entity},
// {Asset Entity},
// ...
]
}
}
Read pairs
GET /pairs
This API will return MTG information about 4swap
Response
json
{
"ts": 1627697766503,
"data": {
"pairs": [
// {Pair Entity},
// ...
],
"pair_count": 75,
"transaction_count_24h": 25134,
"volume_24h": "5189724.64904556",
"fee_24h": "13687.38904891",
"ts": 1627697766503,
}
}
Read pairs (CMC compatible version)
GET /cmc/pairs
The API will respond all supported pairs. It's compatible with Coinmarketcap's requirements.
Response
json
{
"ts": 1627697766503,
"data": {
// combination of 2 crypto's asset_ids
"05c5ac01-31f9-4a69-aa8a-ab796de1d041_31d2ea9c-95eb-3355-b65b-ba096853bc18": {
// Monero's asset id
"base_id": "05c5ac01-31f9-4a69-aa8a-ab796de1d041",
"base_name": "Monero",
"base_symbol": "XMR",
// pUSD's asset id
"quote_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"quote_name": "Pando USD",
"quote_symbol": "pUSD",
"last_price": "235.830040473787049",
"base_volume": "1.87552947",
"quote_volume": "439.96755122"
},
// ...
}
}
Read statistics
GET /stats/markets?dur=:dur
This API will respond historical market statistics.
Params
Name | Type | In | Required | Description |
---|---|---|---|---|
dur | string | url | false | The duration of returning data. for example, 4320h means latest 180 days |
Response
json
{
"ts": 1627697766503,
"data": [
{
"ts": 1617408000,
"date": "2021-04-03T00:00:00Z",
// liquidity in US dollar
"value": "88919122.02992768",
// volume in US dollar
"volume": "10727320.64681277"
},
// ...
]
}
Read statistics of pair
GET /stats/markets/:base/:quote
This API will respond historical market statistics specified by base and quote asset.
Params
Name | Type | In | Required | Description |
---|---|---|---|---|
base | uuid | url | true | The base asset id |
quote | uuid | url | true | The quote asset id |
dur | string | url | false | The duration of returning data. for example, 4320h means latest 180 days |
Response
json
{
"ts": 1627697766503,
"data": [
{
"ts": 1617408000,
"date": "2021-04-03T00:00:00Z",
// liquidity in US dollar
"value": "88919122.02992768",
// volume in US dollar
"volume": "10727320.64681277"
},
// ...
]
}
Read candlestick data
GET /stats/markets/:base/:quote/kline/v2?dur=:dur
This API will respond the candlestick data specified by base and quote asset.
Params
Name | Type | In | Required | Description |
---|---|---|---|---|
base | uuid | url | true | The base asset id |
quote | uuid | url | true | The quote asset id |
dur | string | url | false | The duration of returning data. for example, 4320h means latest 180 days |
Response
json
{
"ts": 1627697766503,
"data": [
[
// timestamp
1612148400,
// price of base / quote
"0.039304863681",
// price of quote / base
"25.442131511901"
]
// ...
]
}
Read order
AUTHORIZATION REQUIRED
GET /orders/:follow_id
This API will respond the order detail related to the follow id.
Params
Name | Type | In | Required | Description |
---|---|---|---|---|
follow_id | uuid | url | true | The follow id to trace the order |
Response
json
{
"data": {
"id": "87ae5014-d20f-4cf1-b530-8771137e4e0e",
"created_at": "2020-09-15T03:35:34Z",
"user_id": "8017d200-7870-4b82-b53f-74bae1d2dad7",
"state": "Done", // order status Trading/Rejected/Done
"pay_asset_id": "6cfe566e-4aad-470b-8c9a-2fd35b49c68d",
"fill_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"pay_amount": "1",
"fill_amount": "00025725",
"min_amount": "0.0002521",
"routes": "1bv",
"route_assets": [
"6cfe566e-4aad-470b-8c9a-2fd35b49c68d",
"c6d0c728-2624-429b-8e0d-d9d19b6592fa"
],
"transactions": [
{
"id": "87ae5014-d20f-4cf1-b530-8771137e4e0e",
"created_at": "2020-09-15T03:35:34Z",
"user_id": "8017d200-7870-4b82-b53f-74bae1d2dad7",
"type": "Swap",
"base_asset_id": "6cfe566e-4aad-470b-8c9a-2fd35b49c68d",
"quote_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"base_amount": "1",
"quote_amount": "-0.00025725",
"fee_asset_id": "6cfe566e-4aad-470b-8c9a-2fd35b49c68d",
"fee_amount": "0.003",
"pay_asset_id": "6cfe566e-4aad-470b-8c9a-2fd35b49c68d",
"filled_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"funds": "1",
"amount": "0.00025725"
}
]
}
}
Read transactions
GET /transactions?cursor=:next_cursor&limit=:limit
This API will respond the order detail related to the follow id.
Params
Name | Type | In | Required | Description |
---|---|---|---|---|
next_cursor | number | url | false | The next cursor to fetch next page |
limit | number | url | false | The limit of returned items |
Response
json
{
"ts": 1682394079412,
"data": {
"transactions": [
{
"id": "5fa1ee98-9deb-55b6-9f3b-7d6ffe924859",
"created_at": "2023-04-25T03:40:58Z",
"type": "Swap",
"base_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"quote_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"base_amount": "0.09419758",
"quote_amount": "-0.00007263",
"fee_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"fee_amount": "0.00028259",
"pay_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"filled_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"funds": "0.09419758",
"amount": "0.00007263",
"value": "1.99",
"fee_value": "0",
"follow_id": "333a5cab-3e91-4126-8b9f-881812422260",
"liquidity": "0"
},
{
"id": "d9113ac9-da9c-3087-b3a0-9ee582cb50ca",
"created_at": "2023-04-25T03:40:58Z",
"type": "Swap",
"base_asset_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"quote_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"base_amount": "2",
"quote_amount": "-0.09419758",
"fee_asset_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"fee_amount": "0.006",
"pay_asset_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"filled_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"funds": "2",
"amount": "0.09419758",
"value": "2",
"fee_value": "0",
"follow_id": "333a5cab-3e91-4126-8b9f-881812422260",
"liquidity": "0"
},
{
"id": "0fbe20db-824d-59ad-9495-56b7dcd37e7d",
"created_at": "2023-04-25T03:39:24Z",
"type": "Swap",
"base_asset_id": "9682b8e9-6f16-3729-b07b-bc3bc56e5d79",
"quote_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"base_amount": "2.04106458",
"quote_amount": "-0.00007264",
"fee_asset_id": "9682b8e9-6f16-3729-b07b-bc3bc56e5d79",
"fee_amount": "0.00612319",
"pay_asset_id": "9682b8e9-6f16-3729-b07b-bc3bc56e5d79",
"filled_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"funds": "2.04106458",
"amount": "0.00007264",
"value": "1.99",
"fee_value": "0",
"follow_id": "c6f4539f-5a96-4355-a397-d244dee2951c",
"liquidity": "0"
}
],
"pagination": {
"next_cursor": "36115195",
"has_next": true
}
}
}
Read transactions of pair
GET transactions/:base/:quote?cursor=:next_cursor&limit=:limit
This API will respond a list of transactions of the specified pair.
Params
Name | Type | In | Required | Description |
---|---|---|---|---|
next_cursor | number | url | false | The next cursor to fetch next page |
limit | number | url | false | The limit of returned items |
base | uuid | url | true | The base asset id |
quote | uuid | url | true | The quote asset id |
Response
json
{
"ts": 1682394079412,
"data": {
"transactions": [
{
"id": "5fa1ee98-9deb-55b6-9f3b-7d6ffe924859",
"created_at": "2023-04-25T03:40:58Z",
"type": "Swap",
"base_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"quote_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"base_amount": "0.09419758",
"quote_amount": "-0.00007263",
"fee_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"fee_amount": "0.00028259",
"pay_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"filled_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"funds": "0.09419758",
"amount": "0.00007263",
"value": "1.99",
"fee_value": "0",
"follow_id": "333a5cab-3e91-4126-8b9f-881812422260",
"liquidity": "0"
},
{
"id": "d9113ac9-da9c-3087-b3a0-9ee582cb50ca",
"created_at": "2023-04-25T03:40:58Z",
"type": "Swap",
"base_asset_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"quote_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"base_amount": "2",
"quote_amount": "-0.09419758",
"fee_asset_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"fee_amount": "0.006",
"pay_asset_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"filled_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"funds": "2",
"amount": "0.09419758",
"value": "2",
"fee_value": "0",
"follow_id": "333a5cab-3e91-4126-8b9f-881812422260",
"liquidity": "0"
},
{
"id": "0fbe20db-824d-59ad-9495-56b7dcd37e7d",
"created_at": "2023-04-25T03:39:24Z",
"type": "Swap",
"base_asset_id": "9682b8e9-6f16-3729-b07b-bc3bc56e5d79",
"quote_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"base_amount": "2.04106458",
"quote_amount": "-0.00007264",
"fee_asset_id": "9682b8e9-6f16-3729-b07b-bc3bc56e5d79",
"fee_amount": "0.00612319",
"pay_asset_id": "9682b8e9-6f16-3729-b07b-bc3bc56e5d79",
"filled_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"funds": "2.04106458",
"amount": "0.00007264",
"value": "1.99",
"fee_value": "0",
"follow_id": "c6f4539f-5a96-4355-a397-d244dee2951c",
"liquidity": "0"
}
],
"pagination": {
"next_cursor": "36115195",
"has_next": true
}
}
}
Read transactions of me
AUTHORIZATION REQUIRED
GET transactions/:base/:quote/mine?cursor=:next_cursor&limit=:limit
This API will respond a list of transactions of the specified pair releated to me.
Params
Name | Type | In | Required | Description |
---|---|---|---|---|
next_cursor | number | url | false | The next cursor to fetch next page |
limit | number | url | false | The limit of returned items |
base | uuid | url | true | The base asset id |
quote | uuid | url | true | The quote asset id |
Response
json
{
"ts": 1682394079412,
"data": {
"transactions": [
{
"id": "5fa1ee98-9deb-55b6-9f3b-7d6ffe924859",
"created_at": "2023-04-25T03:40:58Z",
"type": "Swap",
"base_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"quote_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"base_amount": "0.09419758",
"quote_amount": "-0.00007263",
"fee_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"fee_amount": "0.00028259",
"pay_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"filled_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"funds": "0.09419758",
"amount": "0.00007263",
"value": "1.99",
"fee_value": "0",
"follow_id": "333a5cab-3e91-4126-8b9f-881812422260",
"liquidity": "0"
},
{
"id": "d9113ac9-da9c-3087-b3a0-9ee582cb50ca",
"created_at": "2023-04-25T03:40:58Z",
"type": "Swap",
"base_asset_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"quote_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"base_amount": "2",
"quote_amount": "-0.09419758",
"fee_asset_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"fee_amount": "0.006",
"pay_asset_id": "31d2ea9c-95eb-3355-b65b-ba096853bc18",
"filled_asset_id": "64692c23-8971-4cf4-84a7-4dd1271dd887",
"funds": "2",
"amount": "0.09419758",
"value": "2",
"fee_value": "0",
"follow_id": "333a5cab-3e91-4126-8b9f-881812422260",
"liquidity": "0"
},
{
"id": "0fbe20db-824d-59ad-9495-56b7dcd37e7d",
"created_at": "2023-04-25T03:39:24Z",
"type": "Swap",
"base_asset_id": "9682b8e9-6f16-3729-b07b-bc3bc56e5d79",
"quote_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"base_amount": "2.04106458",
"quote_amount": "-0.00007264",
"fee_asset_id": "9682b8e9-6f16-3729-b07b-bc3bc56e5d79",
"fee_amount": "0.00612319",
"pay_asset_id": "9682b8e9-6f16-3729-b07b-bc3bc56e5d79",
"filled_asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
"funds": "2.04106458",
"amount": "0.00007264",
"value": "1.99",
"fee_value": "0",
"follow_id": "c6f4539f-5a96-4355-a397-d244dee2951c",
"liquidity": "0"
}
],
"pagination": {
"next_cursor": "36115195",
"has_next": true
}
}
}
Create action
DEPRECATED
POST /actions
This is an API to generate an encrypted transfer by provided action protocol data. It's useful if you don't want to sign and encrypt the transaction memo yourself.
Params
Name | Type | In | Required | Description |
---|---|---|---|---|
action | string | json | true | action protocol data |
amount | string | json | false | amount of transaction |
asset_id | string | json | false | asset uuid of transaction |
broker_id | string | json | false | broker id, leave it empty to use 4swap's default broker |
trace_id | string | json | false | an UUID to trace the transaction. |
TIP
Don't use this API if you want to swap frequently, it's not efficient. You should generate memo locally instead.
INFO
Field amount
and asset_id
are optional. If you provide them, the API will send request to Mixin Network and create a payment code
and code_url
for you.
If you're building a dApp or a WebApp, it could be useful to let users pay for your service by Mixin Network compatible wallet, like Messenger and Fennec.
Response
json
{
"ts": 1627697766503,
"data": {
// the encrypted action data
"action": "...",
// the code and the code url, only available if you provide `amount` and `asset_id`
// they could be used to invoke Mixin Network compatible wallet, like Messenger and Fennec.
"code": "d294380f-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"code_url": "mixin://codes/d294380f-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
// an UUID to trace the transfer
"follow_id": "yyyyyyyy-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}