Trading API (v1)
Hashgreen DEX provides a set of API to aid traders to list markets, get order books, and create/cancel orders. A few things to note:
While we currently do not impose strict rate limits and authentication, please use our API respectfully, and we withhold rights to impose access restrictions in future versions.
Please provide reference to this API and the Hashgreen DEX if you are using this API and publicizing products built on top of our API. Let us know your successful story at [email protected] and we are happy to link to your products on our project landing page.
The API is in its beta, and we are constantly adding new features before finalizing a stable version. Let us know if there are any features you would like to add!
Token Retrievalβ
Before using private APIs, please retrieve an anonymous token for order management. Follow the instructions below to copy your token on the website.
Store this token in a safe place as exposing this token would allow other parties to access your trade history and operate your orders.
/markets
(public)β
List Marketsβ
Endpointβ
[GET] https://hash.green/api/v1/markets
Parametersβ
No parameters
Responsesβ
A list of markets (type: List[Market]
).
Example Responseβ
{
"code": 200,
"msg": "ok",
"data": [
{
"id": "61dc1d387d9b5a6756c0d0a2",
"base_ccy": {
"id": "61717ed8b30c4dc5c0e21f6c",
"code": "XCH",
"name": "Chia",
"type": 1,
"status": 2,
"multiplier": "1E-12",
"precision": 12,
"min_amount_display": "0.001",
"max_supply_display": "0",
"total_supply_display": "24101288",
"circulating_supply_display": "3101288",
"launch_at": "1970-01-01T00:00:00.000Z",
"created_at": "2022-02-16T21:57:14.796Z",
"updated_at": "2022-02-16T21:57:14.796Z"
},
"quote_ccy": {
"id": "61d908b574779a699635c508",
"asset_id": "6d95dae356e32a71db5ddcb42224754a02524c615c5fc35f568c2af04774e589",
"code": "USDS",
"name": "Stably USD",
"description": "Stably USD is a one-to-one U.S. Dollar backed, redeemable stablecoin. U.S. Dollar collateral is held in FDIC-insured trust accounts managed by Prime Trust through Stablyβs platform.",
"type": 2,
"status": 2,
"multiplier": "0.001",
"precision": 3,
"min_amount_display": "0.1",
"max_supply_display": "1000000000",
"total_supply_display": "1000000000",
"circulating_supply_display": "154677",
"links": {
"website": "https://www.stably.io/"
},
"icon_url": "https://zed-assets.s3.ca-central-1.amazonaws.com/icons/usds.jpg",
"launch_at": "2021-11-17T00:00:00.000Z",
"created_at": "2022-02-16T21:57:14.792Z",
"updated_at": "2022-02-16T21:57:14.792Z"
},
"code": "XCH-USDS",
"status": 2,
"info_ccy_name": "quote_ccy",
"is_fiat": true,
"price_precision": 2,
"base_amount_precision": 3,
"order_no": 1000,
"created_at": "2022-02-16T21:57:01.979Z",
"updated_at": "2022-02-16T21:57:01.979Z"
}
]
}
Get Marketβ
Endpointβ
[GET] https://hash.green/api/v1/markets/{code}
Parametersβ
Name | Description |
---|---|
code | Market Code. |
Responsesβ
A market (type: Market
).
Example Responseβ
{
"code": 200,
"msg": "ok",
"data": {
"id": "61dc1d387d9b5a6756c0d0a2",
"base_ccy": {
"id": "61717ed8b30c4dc5c0e21f6c",
"code": "XCH",
"name": "Chia",
"type": 1,
"status": 2,
"multiplier": "1E-12",
"precision": 12,
"min_amount_display": "0.001",
"max_supply_display": "0",
"total_supply_display": "24101288",
"circulating_supply_display": "3101288",
"launch_at": "1970-01-01T00:00:00.000Z",
"created_at": "2022-02-16T21:57:14.796Z",
"updated_at": "2022-02-16T21:57:14.796Z"
},
"quote_ccy": {
"id": "61d908b574779a699635c508",
"asset_id": "6d95dae356e32a71db5ddcb42224754a02524c615c5fc35f568c2af04774e589",
"code": "USDS",
"name": "Stably USD",
"description": "Stably USD is a one-to-one U.S. Dollar backed, redeemable stablecoin. U.S. Dollar collateral is held in FDIC-insured trust accounts managed by Prime Trust through Stablyβs platform.",
"type": 2,
"status": 2,
"multiplier": "0.001",
"precision": 3,
"min_amount_display": "0.1",
"max_supply_display": "1000000000",
"total_supply_display": "1000000000",
"circulating_supply_display": "154677",
"links": {
"website": "https://www.stably.io/"
},
"icon_url": "https://zed-assets.s3.ca-central-1.amazonaws.com/icons/usds.jpg",
"launch_at": "2021-11-17T00:00:00.000Z",
"created_at": "2022-02-16T21:57:14.792Z",
"updated_at": "2022-02-16T21:57:14.792Z"
},
"code": "XCH-USDS",
"status": 2,
"info_ccy_name": "quote_ccy",
"is_fiat": true,
"price_precision": 2,
"base_amount_precision": 3,
"order_no": 1000,
"created_at": "2022-02-16T21:57:01.979Z",
"updated_at": "2022-02-16T21:57:01.979Z"
}
}
/trades
(public)β
Get Market Statisticsβ
Note: we currently support market statistics over a 24 hours duration.
Endpointβ
[GET] https://hash.green/api/v1/trades/statistics
Parametersβ
Name | Description |
---|---|
market_id | Market ID (Optional, blank to retrieve all markets). |
Responsesβ
The requested market stat (type: MarketStat
) or list of market stats when the market_id
is not provided (type: List[MarketStat]
).
Example Responseβ
market_id
provided:
{
"code": 200,
"msg": "ok",
"data": {
"id": "61dc1d387d9b5a6756c0d0a2",
"code": "XCH-USDS",
"price": "69.00",
"usd": "69.00",
"high": "69.40",
"low": "69.00",
"base_volume": "3.500",
"usd_volume": "241.85",
"changed": "-3.10",
"fully_diluted_market_cap": "1662988872",
"updated_at": "2022-03-15T03:33:05.387Z"
}
}
market_id
not provided:
{
"code": 200,
"msg": "ok",
"data": [
{
"id": "61dc1d387d9b5a6756c0d0a2",
"price": "69.00",
"usd": "69.00",
"high": "69.40",
"low": "69.00",
"base_volume": "3.500",
"usd_volume": "241.85",
"changed": "-3.10",
"fully_diluted_market_cap": "1662988872",
"updated_at": "2022-03-15T03:33:05.387Z"
}
]
}
Get Order Bookβ
Endpointβ
[GET] https://hash.green/api/v1/trades/book
Parametersβ
Name | Description |
---|---|
market_id | Market ID. |
Responsesβ
A map with the following fields:
Name | Type | Description |
---|---|---|
market_id | string | Market ID echo. |
asks | list of BookRow | Order book rows on the ask side. |
bids | list of BookRow | Order book rows on the bid side. |
Example Responseβ
{
"code": 200,
"msg": "ok",
"data": {
"market_id": "61dc1d387d9b5a6756c0d0a2",
"asks": [
[
"87.00",
"1.000",
"17.266",
"1.000000000000",
"87.000"
]
],
"bids": [
[
"71.05",
"0.008",
"0.008",
"0.008078817734",
"0.574"
]
]
}
}
Get Trade Historyβ
Endpointβ
[GET] https://hash.green/api/v1/trades/history
Parametersβ
Name | Description |
---|---|
market_id | Market ID. |
Responsesβ
A list of trades (type: List[Trade]
).
Example Responseβ
{
"code": 200,
"msg": "ok",
"data": [
{
"id": "6229996bdf38d9336a11492a",
"market_id": "61dc1d387d9b5a6756c0d0a2",
"price": "70.00",
"side": 2,
"base_amount_display": "2.000000000000",
"ts": "2022-03-10T06:28:48.114Z"
},
{
"id": "62299893df38d9336a114928",
"market_id": "61dc1d387d9b5a6756c0d0a2",
"price": "70.00",
"side": 2,
"base_amount_display": "2.000000000000",
"ts": "2022-03-10T06:27:10.710Z"
}
]
}
/orders
(private)β
List Ordersβ
Endpointβ
[GET] https://hash.green/api/v1/orders
Headerβ
Name | Value |
---|---|
Authorization | Bearer ${YOUR_TOKEN} |
Parametersβ
Name | Description |
---|---|
market_id | Market ID. |
status | Order status. |
Responsesβ
A list of orders (type: List[Order]
).
Example Responseβ
{
"code": 0,
"data": [
{
"base_amount_display": "string",
"coin_ids": [
"string"
],
"confirmed_height_at": 0,
"created_at": "string",
"id": "string",
"market_id": "string",
"price": "string",
"progress": "string",
"quote_amount_display": "string",
"side": 0,
"status": 0,
"updated_at": "string",
"user_id": "string"
}
],
"msg": "string"
}
Create Orderβ
Endpointβ
[POST] https://hash.green/api/v1/orders
Headerβ
Name | Value |
---|---|
Authorization | Bearer ${YOUR_TOKEN} |
Content-Type | application/x-www-form-urlencoded |
Bodyβ
Name | Type | Description |
---|---|---|
offer | string | Offer file content. |
Responsesβ
The submitted order (type: Order
).
Example Responseβ
{
"code": 0,
"data": {
"base_amount_display": "string",
"coin_ids": [
"string"
],
"confirmed_height_at": 0,
"created_at": "string",
"id": "string",
"market_id": "string",
"price": "string",
"progress": "string",
"quote_amount_display": "string",
"side": 0,
"status": 0,
"updated_at": "string",
"user_id": "string"
},
"msg": "string"
}
Cancel Orderβ
Endpointβ
[DELETE] https://hash.green/api/v1/orders/{order_id}
Headerβ
Name | Value |
---|---|
Authorization | Bearer ${YOUR_TOKEN} |
Parametersβ
Name | Description |
---|---|
order_id | Order ID. |
Responsesβ
The canceled order (type: Order
).
Example Responseβ
{
"code": 0,
"data": {
"base_amount_display": "string",
"coin_ids": [
"string"
],
"confirmed_height_at": 0,
"created_at": "string",
"id": "string",
"market_id": "string",
"price": "string",
"progress": "string",
"quote_amount_display": "string",
"side": 0,
"status": 0,
"updated_at": "string",
"user_id": "string"
},
"msg": "string"
}
Schemasβ
Market
β
Name | Type | Description |
---|---|---|
id | string | Market ID. |
base_ccy | Currency | Base currency. |
quote_ccy | Currency | Quote currency. |
info_ccy_name | string | Currency to display information for. |
code | string | Market code to display. |
status | Status | Market status enum. |
is_new | boolean | Whether the market is recently added. |
MarketStat
β
Name | Type | Description |
---|---|---|
id | string | Market ID. |
code | string | Market code. |
price | string | Currently price (in quote currency) |
usd | string | Currently price (in USD, approximate) |
high | string | Highest price over duration (in quote currency) |
low | string | Lowest price over duration (in quote currency) |
base_volume | string | Total volume over duration (in base currency) |
usd_volume | string | Total volume over duration (in USD, approximate) |
changed | string | Price change over duration (percentage) |
fully_diluted_market_cap | string | Fully diluted market capitalization (in USD, approximate) |
updated_at | string | Statistics modification time. |
Currency
β
Name | Type | Description |
---|---|---|
id | string | Token ID. |
code | string | Token ticker (up to six letters). |
name | string | Full name. |
status | Status | Token status enum. |
multiplier | string | Conversion from mojo to whole token. |
precision | int | Decimal places needed to represent. |
min_amount_display | string | Minimum amount allowed for trading. |
total_supply_display | string | Total supply of the token. |
links | Map[string, string] | Project links. |
launch_at | timestamp | Launch date of the project. |
BookRow
β
Index | Description |
---|---|
0 | Price. |
1 | Base amount. |
2 | Total base amount. |
3 | Base amount for display. |
4 | Quote amount for display. |
Trade
β
Name | Type | Description |
---|---|---|
id | string | Trade ID. |
market_id | string | Market associated with the trade. |
price | string | The matched price of the trade. |
side | TradeSide | Which side the maker is on. |
base_amount_display | string | The base currency amount of the trade. |
ts | timestamp | Matched time of the trade. |
TradeSide
β
Value | Description |
---|---|
1 | Trade maker is on the bid side. |
2 | Trade maker is on the ask side. |
Order
β
Name | Type | Description |
---|---|---|
user_id | string | User's ID. |
coin_ids | List[string] | A list of hex-encoded coin IDs. |
confirmed_height_at | int | Block height to observe order on chain. |
progress | string | Number of confirmation blocks. |
side | OrderSide | Enum (1 for bid and 2 for ask). |
status | OrderStatus | Order status enum. |
OrderStatus
β
Value | Description |
---|---|
0 | Unspecified. |
1 | Invalid. The coins in the order are partially spent. |
2 | Active. This order is open for matching. |
3 | Matched. This order is now ready to be submitted to the blockchain. |
4 | Clearing. Order was sent to the blockchain but awaiting observance. |
5 | Cleared. Order has been observed on the blockchain. |
6 | Cancelled. Order was soft cancelled. |
Status
β
Value | Description |
---|---|
1 | Disabled. |
2 | Enabled. |