Skip to main content

Energiswap API Endpoints

Introduction

This API reference guide includes a set of endpoints that can be used by market aggregators and developers to collect data from Energiswap. All data is fetched from an underlying subgraph application.​ All Energiswap pairs consist of two different ERC20 tokens. NRG is not a native ERC20 currency in Energiswap. It is represented by WNRG in the pairs.  The canonical WNRG address used by the Energiswap interface is:

0xA55F26319462355474A9F2c8790860776a329aA4

Standards and Conventions

  1. The REST API is open to the public. There is no API authentication required to access the endpoints.

  2. Results are edge-cached for 1 minute (or 60 seconds) and refreshed in the background (stale-while-revalidate

  3. Data is displayed in JSON format.

  4. Prices standardized to the quote currency (USD).

  5. Versioning provided to avoid breaking changes (/v1/assets, /v2/assets, etc.).

  6. Rate limits are 60 requests per hour. ​

Endpoints

The following endpoints are available via the API.

The API servers are:

Testnet: https://apt.test.energiswap.exchange

Mainnet: https://api.energiswap.exchange

This document uses the Mainnet API server in the examples.

/v1/statistics

​The statistics endpoint returns the total liquidity and number of pairs available in Energiswap. ​

Request

​GET https://api.energiswap.exchange/v1/statistics

Response

{
"total_liquidity": 1234.56, // total liquidity denominated in USD
"total_liquidity_NRG": 1234.56, // total liquidity denominated in NRG
"total_pair": 1234 // pair count
}

/v1/summary

​The summary endpoint returns data for the top ~1000 token pairs in Energiswap, sorted by liquidity. ​

Request

GET https://api.energiswap.exchange/v1/summary

Response

{
"0x..._0x...": { // the asset ids of the ERC20 tokens (i.e. token addresses), joined by an underscore
"last_price": 1.234, // denominated in token0/token1
"base_volume": // last 24h volume denominated in token0
"quote_volume": 1234.56, // last 24h volume denominated in token1
"liquidity": 1234.56, // liquidity denominated in USD
"liquidity_NRG": 1234.56 // liquidity denominated in NRG
},
// ...
}

/v1/assets

​The assets endpoint returns summary data for each token available on Energiswap. ​

Request

​GET https://api.energiswap.exchange/v1/assets

Response

{
// ...,
"0x...": { // the address of the ERC2020 token
"name": "...", // not necessarily included for ERC20 tokens
"symbol": "...", // not necessarily included for ERC20 tokens
"last_price": 1.234, // denominated in USD
"maker_fee": 0, // always 0
"taker_fee": 0.003, // always 0.003 i.e. .3%
},
// ...
}

/v1/lpprices

​The LPPrices endpoint returns LP token prices in USD for all pairs. ​

Request

​GET https://api.energiswap.exchange/v1/lpprices 

Response

{
id: Address, // ERC-20 address of token pair
lpPriceUSD: number, // LP token price in USD
totalSupply: number, // Total number of LP tokens of this pair
token0: { // First token of the pair
id: Address, // ERC-20 address of token0
name: string, // token0 name
symbol: string, // token0 symbol
priceNRG: number, // token0 price in NRG unit
},
token1: { // Second token of the pair
id: Address, // ERC-20 address of token1
name: string, // token1 name
symbol: string, // token1 symbol
priceNRG: number, // token1 price in NRG unit
},
reserve0: number, // quantity of token0 in pool
reserve1: number, // quantity of token1 in pool
reserveValueNRG: number, // total value of this pair in NRG unit
reserveValueUSD: number, // total value of this pair in USD
},
// ...
}

/v1/tickers

The ticker endpoint returns a 24-hour pricing and volume summary for each token pair available on Energiswap. ​

Request

​GET https://api.energiswap.exchange/v1/tickers 

Response

{
"0x..._0x...": { // the asset ids of BNB and ERC20 tokens, joined by an underscore
"base_name": "...", // token0 name
"base_symbol": "...", // token0 symbol
"base_id": "0x...", // token0 address
"quote_name": "...", // token1 name
"quote_symbol": "...", // token1 symbol
"quote_id": "0x...", // token1 address
"last_price": 1.234, // the mid price as token1/token0
"base_volume": 123.456, // denominated in token0
"quote_volume": 1234.56, // denominated in token1
"liquidity": 1234.56, // liquidity denominated in USD
"liquidity_NRG": 1234.56 // liquidity denominated in NRG
},
// ...
}

/v1/orderbook/pair

​Returns simulated orderbook data for the given Energiswap pair. The pair address is the address of the two tokens in an orderbook.

Since Energiswap has a continuous orderbook, fixed amounts in an interval are chosen for bids and asks, and prices are derived from the Energiswap formula (accounting for both slippage and fees paid to liquidity pairs). ​

Request

​GET https://api.energiswap.exchange/v1/orderbook/pair

URL Parameters

pair: The asset ids of two ERC20 tokens, joined by an underscore, e.g. 0x..._0x.... The first token address is considered the base in the response. ​

Response

{
"updated_at": 1234567, // UNIX timestamp
"bids": [
[12, 1.2], // denominated in base token, quote token/base token
[12, 1.1], // denominated in base token, quote token/base token
// ...
],
"asks": [
[12, 1.3], // denominated in base token, quote token/base token
[12, 1.4], // denominated in base token, quote token/base token
// ...
]
}

/v1/trades/pair

​Returns all swaps in the last 24 hours for the given Energiswap pair.​ The pair address is the address of the two tokens in either order. The first address is considered the base in the response. ​

Request

​GET https://api.energiswap.exchange/v1/trades/pair 

URL Parameters

  • pair: The asset ids of two ERC20 tokens, joined by an underscore, e.g. 0x..._0x.... The first token address is considered the base in the response.

Response

[
{
"trade_id": "...",
"price": "1.234", // denominated in quote token/base token
"base_volume": "123.456", // denominated in base token
"quote_volume": "1234.56", // denominated in quote token
"trade_timestamp": 1234567, // UNIX timestamp
"type": "buy" // "buy"/"sell"/"borrow-both"/"???"
},
// ...
]