# REST API

### URL

<https://api.benswap.cash/>

### List of all public API endpoints

\*If the public RPC node is down, some API endpoints may be temporarily unavailable.

#### BCH

| Latest BCH price.                      | GET /api/bch/price         |
| -------------------------------------- | -------------------------- |
| Some history prices in the past 7 days | GET /api/bch/historyPrices |

#### smartBCH

| Latest SBCH Price.                                | GET /api/smartbch/price                                                                         |
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| General Info.                                     | GET /api/smartbch/info                                                                          |
| Latest block height.                              | GET /api/smartbch/block                                                                         |
| Closest block height at Unix timestamp (seconds). | <p>GET /api/smartbch/block/{timestamp} </p><p>GET /api/smartbch/block?timestamp={timestamp}</p> |
| Unix timestamp (seconds) of the latest block.     | GET /api/smartbch/timestamp                                                                     |
| Unix timestamp (seconds) at specific block.       | <p>GET /api/smartbch/timestamp/{block}</p><p>GET /api/smartbch/timestamp?block={block}</p>      |
| RPC nodes.                                        | GET /api/smartbch/rpc                                                                           |
| Check RPC node by name.                           | <p>GET /api/smartbch/rpc/{name} </p><p>GET /api/smartbch/rpc?name={name}</p>                    |

#### SEP20

| SEP-20 token basic information (id is token contract address). Works for all SEP-20 tokens.                                                                                                                 | <p>GET /api/sep20/tokenbasics/{id}</p><p>GET /api/sep20/tokenbasics?id={id}</p> |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| SEP-20 token information (id is token contract address). The token has to be already registered in the /assets folder of [BenSwap assets repository](https://github.com/BenTokenFinance/benswapbch-assets). | <p>GET /api/sep20/token/{id}</p><p>GET /api/sep20/token?id={id}</p>             |
| SEP-20 token liquidity detail across multiple DEXes. Works for all SEP-20 tokens.                                                                                                                           | <p>GET /api/sep20/liquidity/{id}</p><p>GET /api/sep20/liquidity?id={id}</p>     |

#### EBEN

| Current supply summary.                                          | GET /api/eben/supply      |
| ---------------------------------------------------------------- | ------------------------- |
| Current total supply.                                            | GET /api/eben/total       |
| Current total burned.                                            | GET /api/eben/burned      |
| Current circulating supply.                                      | GET /api/eben/circulating |
| Current staked info in major LPs, pools, and DeFi contracts etc. | GET /api/eben/staked      |
| Current EBEN price (per USD).                                    | GET /api/eben/priceUsd    |
| Current EBEN price (per SBCH).                                   | GET /api/eben/priceSbch   |

#### DEX

**Warning**: USD based data are missing before block 820000. Statistics like "totalVolumeUsd", "volumeUsd" only include volume after block 820000, and statistics like "priceUsd", "liquidityUsd" will be 0 if you use a block number less than 820000. USD data are also distorted between May and September in 2022 due to the de-pegging of the previous de facto stable coin: flexUSD.

| DEX stats.                                                                                                                                                                                                                | GET /api/dex/stats                                                                                                                      |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| DEX stats at specific block.                                                                                                                                                                                              | <p>GET /api/dex/stats/{block}</p><p>GET /api/dex/stats?block={block}</p>                                                                |
| Pairs that have enough liquidity.                                                                                                                                                                                         | GET /api/dex/pairs                                                                                                                      |
| Single pair data (id is LP address). Must have enough liquidity on DEX.                                                                                                                                                   | <p>GET /api/dex/pair/{id}</p><p>GET /api/dex/pair?id={id}</p>                                                                           |
| Single pair at specific block (id is LP address).                                                                                                                                                                         | <p>GET /api/dex/pair/{id}/{block}</p><p>GET /api/dex/pair?id={id}\&block={block}</p>                                                    |
| Tokens that have enough liquidity.                                                                                                                                                                                        | GET /api/dex/tokens                                                                                                                     |
| Single token data (id is token address). Must have enough liquidity on DEX.                                                                                                                                               | <p>GET /api/dex/token/{id}</p><p>GET /api/dex/token?id={id}</p>                                                                         |
| Single token at specific block (id is token address).                                                                                                                                                                     | <p>GET /api/dex/token/{id}/{block}</p><p>GET /api/dex/token?id={id}\&block={block}</p>                                                  |
| Latest candlestick trading data for a token (id is token address).  "baseCurrency" has to be either "bch" or "usd". "range" has to be one of these \["1min", "15mins", "1h", "1d", "1w"]. Maximum return is 1000 records. | <p>GET /api/dex/trade/{baseCurrency}/{range}/{id}</p><p>GET /api/dex/trade/{baseCurrency}/{range}?id={id}</p>                           |
| Same as above, but with specific ending time (not inclusive) to get earlier records. "before" has to be a valid Unix timestamp (seconds).                                                                                 | <p>GET /api/dex/trade/{baseCurrency}/{range}/{id}/{before}</p><p>GET /api/dex/trade/{baseCurrency}/{range}?id={id}\&before={before}</p> |

#### **Lottery**

| Get lottery ticket data by its NFT ID. | <p>GET /api/lotteryTicket/{id}</p><p>GET /api/lotteryTicket?id={id}</p> |
| -------------------------------------- | ----------------------------------------------------------------------- |

#### PokéBen

| Get a PokéBen's metadata by PokéBen ID.           | <p>GET /api/pokeben/data/{id}</p><p>GET /api/pokeben/data?id={id}</p>                         |
| ------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| Get a PokéBen item's metadata by Item ID.         | <p>GET /api/pokeben/item/{id}</p><p>GET /api/pokeben/item?id={id}</p>                         |
| Current total number of PokéBen.                  | GET /api/pokeben/supply                                                                       |
| Current total number of PokéBen items.            | GET /api/pokeben/itemSupply                                                                   |
| Top PokéBens ranking by power. 20 items per page. | <p>GET /api/pokeben/ranking/power/{page}</p><p>GET /api/pokeben/ranking/power?page={page}</p> |
| Top PokéBens ranking by level. 20 items per page. | <p>GET /api/pokeben/ranking/level/{page}</p><p>GET /api/pokeben/ranking/level?page={page}</p> |

#### Bridge

| Current information of all bridged tokens. | GET /api/bridge |
| ------------------------------------------ | --------------- |

#### Others

| Unix timestamp (milliseconds) of server time | GET /api/time |
| -------------------------------------------- | ------------- |
