I am using the Uniswap v2 api subgraph but I am running into a bit of an issue that I cannot resolve.
Basically I want to query the api to get the latest token swaps of a chosen token and Eth. Using Eth's current price I can accurately get a real-time price of the given token.
But in order to make pair information requests to the api you need to know the pair ID to begin with.
How can I possibly get the pair ID if the pair ID is not stored or apart of the chosen token's id? I can dynamically get the token's ID from another API and I can use that to query info from Uniswap's api however there seems to be no way to get the actual pairs ID in order to determine the latest swaps.
Here is a sandbox of Uniswaps subgraph API in case anyone wants to try and see if they can pull a coin's pair ID address.
https://thegraph.com/explorer/subgraph/uniswap/uniswap-v2
Edit: to be clear I can get the Pair ID addresses manually by going to uniswap.info however this is not what I want to do. I want to be able to dynamically search for any erc-20 token and then use that token to pull the latest swaps using the pair ID.
Best Answer
You can write a query to filter all the liquidity pairs on Uniswap and get the pair address