How to get token price with Uniswap v3 GraphQL API

Viewed 1324

I am going to get token price with Uniswap v3 GraphQL API from Spring boot.

So I tried to test in Postman with URL : https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3 and query :

{
  factories(first: 5) {
    id
    poolCount
    txCount
    totalVolumeUSD
  }
  bundles(first: 5) {
    id
    ethPriceUSD
  }
}

But I couldn't get the result like in thegraph.com.

Please help me with how I can get the token price with Uniswap v3 GraphQL API.

1 Answers

Postman:

  • Ensure the method is POST and not GET
  • Ensure the body of the request is raw -> JSON
  • Ensure the query is formatted properly {"query":"{ factories(first: 5) { id poolCount txCount totalVolumeUSD } bundles(first: 5) { id ethPriceUSD }}"}

Postman Image

Fire away!

Related