🤑Trades
Endpoint
GET /api/v1/trades
Description
Understanding the asset_id
Parameter
asset_id
ParameterWhen specifying the asset_id
, you are essentially choosing the token from the liquidity pair you wish to focus on. This choice affects how trades are represented in the response:
Buy or Sell Side: The
side
of each trade (buy or sell) is determined relative to theasset_id
.If the
asset_id
matches the sold token in the swap, the trade is considered a "sell" from the perspective of that asset.Conversely, if the
asset_id
matches the bought token, the trade is viewed as a "buy."
For instance, consider a trading pair of BNB (token0) and USDT (token1):
If
asset_id
is set to BNB, then:A swap exchanging BNB for USDT is shown as a "sell" because BNB is being sold.
A swap exchanging USDT for BNB is shown as a "buy" because BNB is being bought.
If
asset_id
is set to USDT, then:The perspective reverses: swaps exchanging BNB for USDT are seen as "buys" (buying USDT), and those exchanging USDT for BNB are "sells" (selling USDT).
Price Representation
Price Value: The
price
field in the response reflects the price of theasset_id
targeted in each swap. This means the price is presented from the perspective of theasset_id
chosen, ensuring consistency with the side (buy or sell) designation.
Query String Parameters
asset_id (required): A string in the format <TOKEN_CONTRACT_ADDRESS>:<NETWORK_ID> that identifies the token you are interested in, in the LP pair. This should be either the token1_id or token0_id on the trading pair.
pair_id (required): A string in the format <PAIR_CONTRACT_ADDRESS>:<NETWORK_ID>.
Headers
x-api-key (required): A valid API key.
Example
curl -X GET 'https://data.lynxcrypto.app/api/v1/trades?asset_id=0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c%3A56&pair_id=0x47a90a2d92a8367a91efa1906bfc8c1e05bf10c4%3A56'
-H 'x-api-key: <YOUR_API_KEY>'
Response
[
{
"pair_id": "0x47a90a2d92a8367a91efa1906bfc8c1e05bf10c4:56",
"date": "2024-02-25T04:42:38Z",
"block_number": 36435099,
"chain": 56,
"exchange": "0x3c11f6265ddec22f4d049dde480615735f451646",
"factory_address": "0xdb1d10011ad0ff90774d0c6bb92e5c5c8b4461f7",
"hash": "0xd45e8f41b653a92216ef83f015bb5d7cea7159613bfe402e42459487bc52a721",
"log_index": 128,
"maker": "0xf08b05ef2917249eaad3044b2d00debb345c6048",
"pair_address": "0x47a90a2d92a8367a91efa1906bfc8c1e05bf10c4",
"token0_address": "0x55d398326f99059ff775485246999027b3197955",
"token0_amount": 2.0,
"token0_price": 0.9996537220631725,
"token0_reserves": 652501.8020571235,
"token0_symbol": "usdt",
"token1_address": "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
"token1_amount": 0.005279827279612583,
"token1_price": 378.66909999999996,
"token1_reserves": 545.7530331732752,
"token1_symbol": "wbnb",
"side": "buy",
"price": 378.66909999999996,
"volume": 1.999307444126345
},
{
"pair_id": "0x47a90a2d92a8367a91efa1906bfc8c1e05bf10c4:56",
"date": "2024-02-25T04:42:32Z",
"block_number": 36435097,
"chain": 56,
"exchange": "0x802b65b5d9016621e66003aed0b16615093f328b",
"factory_address": "0xdb1d10011ad0ff90774d0c6bb92e5c5c8b4461f7",
"hash": "0x766eacc0e7e20fe58607a4d8ffc8a5d89530952288af9ae1011bab4b62eff65f",
"log_index": 207,
"maker": "0xc319ddb4e44666872dd7c20055264eacdf2c89d1",
"pair_address": "0x47a90a2d92a8367a91efa1906bfc8c1e05bf10c4",
"token0_address": "0x55d398326f99059ff775485246999027b3197955",
"token0_amount": 2014.83211601201,
"token0_price": 0.9997985555106049,
"token0_reserves": 652499.8020571235,
"token0_symbol": "usdt",
"token1_address": "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
"token1_amount": 5.319753418446827,
"token1_price": 378.6690999999999,
"token1_reserves": 545.7583130005548,
"token1_symbol": "wbnb",
"side": "buy",
"price": 378.6690999999999,
"volume": 2014.426239185183
}
]
Response Codes
200
: Success. Returns the trades for the given pair and token.400
: Bad Request. The asset_id or pair_id were not provided.403: Forbidden. The x-api-key header is not provided or is invalid.
Last updated