Skip to main content

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.

info

Store this token in a safe place as exposing this token would allow other parties to access your trade history and operate your orders.

Export Token #1 Export Token #2 Export Token #3

/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​

NameDescription
codeMarket 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​

NameDescription
market_idMarket 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​

NameDescription
market_idMarket ID.

Responses​

A map with the following fields:

NameTypeDescription
market_idstringMarket ID echo.
askslist of BookRowOrder book rows on the ask side.
bidslist of BookRowOrder 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​

NameDescription
market_idMarket 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
NameValue
AuthorizationBearer ${YOUR_TOKEN}

Parameters​

NameDescription
market_idMarket ID.
statusOrder 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​

NameValue
AuthorizationBearer ${YOUR_TOKEN}
Content-Typeapplication/x-www-form-urlencoded

Body​

NameTypeDescription
offerstringOffer 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​

NameValue
AuthorizationBearer ${YOUR_TOKEN}

Parameters​

NameDescription
order_idOrder 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​

NameTypeDescription
idstringMarket ID.
base_ccyCurrencyBase currency.
quote_ccyCurrencyQuote currency.
info_ccy_namestringCurrency to display information for.
codestringMarket code to display.
statusStatusMarket status enum.
is_newbooleanWhether the market is recently added.

MarketStat​

NameTypeDescription
idstringMarket ID.
codestringMarket code.
pricestringCurrently price (in quote currency)
usdstringCurrently price (in USD, approximate)
highstringHighest price over duration (in quote currency)
lowstringLowest price over duration (in quote currency)
base_volumestringTotal volume over duration (in base currency)
usd_volumestringTotal volume over duration (in USD, approximate)
changedstringPrice change over duration (percentage)
fully_diluted_market_capstringFully diluted market capitalization (in USD, approximate)
updated_atstringStatistics modification time.

Currency​

NameTypeDescription
idstringToken ID.
codestringToken ticker (up to six letters).
namestringFull name.
statusStatusToken status enum.
multiplierstringConversion from mojo to whole token.
precisionintDecimal places needed to represent.
min_amount_displaystringMinimum amount allowed for trading.
total_supply_displaystringTotal supply of the token.
linksMap[string, string]Project links.
launch_attimestampLaunch date of the project.

BookRow​

IndexDescription
0Price.
1Base amount.
2Total base amount.
3Base amount for display.
4Quote amount for display.

Trade​

NameTypeDescription
idstringTrade ID.
market_idstringMarket associated with the trade.
pricestringThe matched price of the trade.
sideTradeSideWhich side the maker is on.
base_amount_displaystringThe base currency amount of the trade.
tstimestampMatched time of the trade.

TradeSide​

ValueDescription
1Trade maker is on the bid side.
2Trade maker is on the ask side.

Order​

NameTypeDescription
user_idstringUser's ID.
coin_idsList[string]A list of hex-encoded coin IDs.
confirmed_height_atintBlock height to observe order on chain.
progressstringNumber of confirmation blocks.
sideOrderSideEnum (1 for bid and 2 for ask).
statusOrderStatusOrder status enum.

OrderStatus​

ValueDescription
0Unspecified.
1Invalid. The coins in the order are partially spent.
2Active. This order is open for matching.
3Matched. This order is now ready to be submitted to the blockchain.
4Clearing. Order was sent to the blockchain but awaiting observance.
5Cleared. Order has been observed on the blockchain.
6Cancelled. Order was soft cancelled.

Status​

ValueDescription
1Disabled.
2Enabled.