Uniswap v3 Subgraph Official Endpoint Now Available on The Graph
If you’re working with Uniswap v3 data, the official subgraph endpoint on The Graph is your fastest way to query decentralized exchange information. This guide explains how to access it, what data you can retrieve, and why it’s more efficient than direct contract calls.
The Uniswap v3 subgraph indexes transactions, pools, and token swaps in real time, making historical and live data accessible through GraphQL. Instead of parsing raw blockchain logs, you can request structured data like liquidity changes, trade volumes, or fee metrics with a single query.
To start, use the endpoint https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3. Whether you’re building analytics dashboards or optimizing trading strategies, this API provides the necessary on-chain data without requiring complex infrastructure.
What is the Uniswap v3 Subgraph?
The Uniswap v3 Subgraph is a structured dataset that indexes and organizes blockchain data from Uniswap v3, making it queryable via The Graph. Developers use it to fetch real-time information on pools, trades, liquidity positions, and fees without parsing raw blockchain logs.
Unlike direct RPC calls, the Subgraph simplifies data access. For example, you can retrieve all active liquidity providers for a specific pool with a single GraphQL query instead of manually processing events. This saves time and reduces errors in decentralized applications (dApps).
Key Features
- Tracks swaps, mints, and burns across all Uniswap v3 pools.
- Stores historical data, enabling analytics like volume trends or fee generation.
- Supports complex queries, such as filtering pools by token pairs or fee tiers.
To integrate it, connect your dApp to the official endpoint: https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3. The Graph’s decentralized network ensures uptime, while the hosted service offers faster responses for testing.
For accurate results, structure queries around indexed fields like token0 or timestamp. Avoid unbounded requests–paginate large datasets using first and skip parameters to optimize performance.
How to access the official Uniswap v3 Subgraph endpoint
Query the Uniswap v3 Subgraph directly using The Graph’s hosted service at https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3. This endpoint provides real-time data on pools, swaps, and liquidity positions. For faster responses, filter queries by specific block ranges or pool addresses.
If you need historical data or higher reliability, consider deploying your own instance of the Uniswap v3 Subgraph. Clone the repository from GitHub, deploy it to a Graph Node, and customize schema or event handlers. Use environment variables to switch between mainnet, Arbitrum, or Optimism deployments.
Key data entities indexed by the Uniswap v3 Subgraph
The Uniswap v3 Subgraph tracks pools, swaps, and positions with granular precision. Each pool entity stores details like token pairs, fees, and liquidity distribution across tick ranges. If you need real-time trade data or liquidity metrics, querying these entities ensures accurate results.
Swaps capture every trade executed on Uniswap v3, including amounts, participants, and transaction hashes. For developers building analytics dashboards, swap data helps track volume trends or identify arbitrage opportunities.
Liquidity and positions
Position entities reveal where liquidity providers (LPs) allocate funds. Each position includes:
- Owner address
- Lower/upper tick bounds
- Liquidity amount
- Fee growth metrics
This data optimizes LP strategy analysis.
Mints, burns, and collects–key events tied to liquidity changes–are also indexed. Monitoring these helps audit protocol activity or calculate fee distributions without scanning raw blockchain logs.
Here’s the HTML-formatted section with concise, actionable content:
Querying pool data from Uniswap v3 Subgraph
To fetch pool data from Uniswap v3 Subgraph, use this GraphQL query structure:
{
pools(first: 5, where: {volumeUSD_gt: 1000000}) {
id
token0 {
symbol
}
token1 {
symbol
}
volumeUSD
}
}
This returns the first 5 pools with USD volume exceeding $1M, including token pairs and trading volume. Adjust first and where parameters for specific needs.
Key fields for pool analysis:
| Field | Description |
|---|---|
totalValueLockedUSD | Total liquidity in USD |
txCount | Number of transactions |
feesUSD | Accumulated fees |
sqrtPrice | Current pool price |
Filter pools by creation time to track new listings:
{
pools(
first: 3
orderBy: createdAtTimestamp
orderDirection: desc
) {
id
createdAtTimestamp
}
}
For price data, combine token0Price and token1Price with timestamp filtering:
{
pools(where: {id: "0x8ad..."}) {
token0Price
token1Price
swaps(orderBy: timestamp, first: 1) {
timestamp
}
}
}
Use skip for pagination when processing large datasets. For real-time updates, subscribe to pool changes via websockets.
Fetching token information using the Subgraph
Query the Uniswap v3 Subgraph for token details by sending a GraphQL request to the official endpoint: https://api.thegraph.com/subgraphs/name/uniswap/uniswap-v3.
Use this query to get basic token data like symbol, name, and decimals:
{
tokens(first: 5) {
id
symbol
name
decimals
}
}
Filter tokens by specific criteria–for example, fetch only those with a certain symbol:
{
tokens(where: {symbol: "USDC"}) {
id
totalSupply
}
}
Retrieve derived data such as trade volume or liquidity by expanding the query with nested fields:
{
tokens(first: 3) {
symbol
volumeUSD
pool {
liquidity
}
}
}
For large datasets, paginate results using skip and first parameters to avoid timeouts.
Check token prices by querying the derived USD value from swaps:
{
token(id: "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984") {
derivedETH
}
}
Combine multiple queries in a single request to reduce API calls–fetch tokens and their top pools simultaneously.
Test queries in the Graph Explorer playground before integrating them into your application.
Tracking swap transactions in Uniswap v3
Query the official Uniswap v3 Subgraph endpoint on The Graph to retrieve swap data efficiently. Use GraphQL queries like swaps(first: 100, orderBy: timestamp, orderDirection: desc) to fetch the latest 100 swaps sorted by time.
Each swap transaction contains key details:
amount0andamount1– token quantities swappedsqrtPriceX96– the square root of the price after swapsenderandrecipient– wallet addresses involvedtransaction.hash– on-chain transaction ID
Filter swaps by specific pools using the pool parameter. For example, to track USDC/WETH swaps, first query the pool address with pools(where: {token0: "0xa0b8...", token1: "0xc02a..."}), then pass the pool ID to your swap query.
For real-time monitoring, set up a WebSocket subscription to the Subgraph. This pushes new swap events instantly instead of polling. The subscription query structure matches regular queries but uses the subscription keyword.
Calculate price impact by comparing sqrtPriceX96 before and after swaps. Convert it to a human-readable price using the formula (sqrtPriceX96 / 2^96)^2. Track large swaps (e.g., >$100k) by adding where: {amountUSD_gt: 100000} to your query.
Store historical swap data locally for analytics. The Subgraph only indexes recent chain data, so periodically archive results if you need long-term analysis. Tools like Dune Analytics complement this for aggregated metrics.
Debug failed swaps by checking the logIndex and origin fields. Failed transactions still appear in the Subgraph but show reverted states. Cross-reference with Etherscan using the transaction hash for full details.
Retrieving liquidity provider positions
To fetch LP positions in Uniswap v3, query the Subgraph endpoint with specific parameters like owner address and pool ID. Use GraphQL syntax to filter active positions where liquidity_gt: 0.
For example, this query retrieves all positions for a given wallet:
{
positions(where: { owner: "0x123...", liquidity_gt: 0 }) {
id
liquidity
tickLower { tickIdx }
tickUpper { tickIdx }
token0 { symbol }
token1 { symbol }
}
}
Handling pagination
Large position sets require pagination. Add first and skip parameters to limit responses:
{
positions(
first: 100,
skip: 0,
where: { owner: "0x123..." }
) { ... }
}
Track returned position IDs to avoid duplicates across paginated requests. The Subgraph indexes new positions within ~1 minute of blockchain confirmation.
Calculating position value
Combine Subgraph data with on-chain calls to NonfungiblePositionManager for real-time pricing. Fetch:
collectable feesviacollect()current tickfrom the pool contractsqrtPriceX96for in-range positions
For inactive positions (liquidity = 0), check the closed flag and query historical fee data separately.
Store position snapshots locally to track performance over time. The Subgraph only maintains current state.
Filtering data by timestamp or block number
To filter Uniswap v3 Subgraph data by timestamp or block number, use where conditions in your GraphQL queries. For example, querying swaps after a specific block looks like this: swaps(where: {blockNumber_gt: 12345678}) { ... }. This efficiently narrows results without post-processing.
Timestamps work similarly but require conversion. Ethereum blocks average 12 seconds, but exact times vary. For precise time-based queries, first map your target timestamp to a block number using tools like Etherscan’s API, then filter by blockNumber_gt or blockNumber_lt.
Handling time ranges
Combine multiple conditions for ranges. To fetch swaps between blocks 15,000,000 and 15,100,000: swaps(where: {blockNumber_gt: 15000000, blockNumber_lt: 15100000}). The same logic applies to timestamps if pre-mapped to blocks.
For recurring queries, store block numbers corresponding to key dates offline. This avoids repeated API calls for timestamp conversions and speeds up subsequent requests.
Optimizing performance
Narrow time windows drastically improve query speed. Avoid unbounded ranges like blockNumber_gt: 0. Instead, chunk large datasets into smaller intervals (e.g., weekly blocks) and aggregate results client-side.
Remember that Subgraph indexes are optimized for exact matches and inequalities. Pairing block filters with token or pool IDs (where: {blockNumber_gt: 15000000, token0: "0xabc..."}) yields the fastest responses.
Handling pagination in large Subgraph queries
Use skip and first for precise control
When querying large datasets from Uniswap v3’s Subgraph, always paginate using skip and first parameters. Start with small batches (e.g., first: 100) to avoid timeouts, then incrementally increase based on response times. For example:{ swaps(first: 100, skip: 200) { id } } fetches records 201-300.
Track your position with skip values stored client-side. Combine this with timestamp-based filtering (where: { timestamp_gt: $lastTimestamp }) to handle real-time data updates without missing entries during pagination.
Optimize with cursor-based pagination
For better performance than skip, use cursor-based pagination with id_gt filtering:{ pools(first: 100, where: { id_gt: $lastId }) }. This method scales linearly while skip becomes slower with deeper pagination.
Always sort by unique fields like id or timestamp when using cursor pagination. For Uniswap v3 swaps, a reliable pattern is:{ swaps(first: 100, orderBy: timestamp, orderDirection: asc, where: { timestamp_gt: $lastTimestamp }) }.
Implement automatic retries with exponential backoff when hitting rate limits. The Graph’s public endpoint may throttle requests during high traffic. Catch HTTP 429 errors and retry after 1s, then 2s, then 4s.
Cache frequently accessed data like token addresses or factory stats locally. For paginated historical queries, consider downloading full datasets overnight via scheduled workers rather than real-time client requests.
Monitor query costs using queryFee in GraphQL responses. Complex paginated queries against large entities (e.g., all Uniswap v3 positions) may require breaking into smaller sub-queries by pool or time range.
For developers building dashboards, pre-aggregate data in your middleware. Instead of paginating through raw swaps, create summary tables that update incrementally as new Subgraph data becomes available.
Common errors and troubleshooting tips
If your queries return empty results, check if the subgraph is synced. Use the Graph Explorer to verify sync status–look for “Synced” instead of “Pending” or “Failed.”
Failed transactions often occur due to incorrect parameter formatting. Ensure timestamps are in seconds, not milliseconds, and addresses are in lowercase with ‘0x’ prefixes.
When encountering “indexing_error” in logs, redeploy the subgraph with updated event handlers. Missing or misconfigured handlers cause indexing to halt.
Slow query responses usually mean inefficient schema design. Add @index directives to frequently queried fields and avoid full-text searches on large datasets.
For “Subgraph not found” errors, confirm the deployment ID matches exactly. Copy it directly from the Graph Explorer interface to avoid typos.
HTTP 504 timeouts suggest overly complex queries. Break them into smaller batches or increase timeout limits in your client configuration.
Price calculation failures in Uniswap v3 often stem from incorrect tick spacing. Verify pool tick spacing matches the fee tier (100 for 1%, 10 for 0.1%).
Persistent issues? Check the official Uniswap v3 subgraph GitHub repository for open issues–many edge cases already have documented solutions.
Comparing Uniswap v3 Subgraph with v2
Uniswap v3’s Subgraph introduces concentrated liquidity, allowing granular tracking of positions within custom price ranges. Unlike v2, where liquidity was spread uniformly, v3 provides precise data on capital efficiency, making it easier to analyze trading pairs with variable fee tiers (0.05%, 0.30%, 1%).
The v3 Subgraph schema now includes Position and Tick entities, reflecting its upgraded architecture. Developers querying active positions or historical fee accruals will notice faster indexing times–v3 optimizes storage by excluding redundant data like unused price ranges, a limitation in v2’s linear model.
For price oracles, v3 offers significant improvements. While v2 relied on time-weighted average prices (TWAPs) from a single liquidity pool, v3 aggregates data across multiple fee tiers, enhancing accuracy. This change reduces manipulation risks and provides more reliable on-chain pricing.
Migrating from v2 to v3 Subgraph requires updating queries to handle non-fungible liquidity positions. For example, fetching all pools in v2 used a simple pools query, whereas v3 demands filtering by feeTier or tickSpacing to isolate specific market conditions.
Despite its complexity, v3’s Subgraph delivers better performance for high-frequency analytics. The Graph’s official endpoint processes ~50% more queries per second for v3 than v2, thanks to optimized indexing of concentrated liquidity data–crucial for building responsive dashboards or arbitrage tools.
FAQ:
What is the Uniswap v3 subgraph official endpoint on The Graph?
The official Uniswap v3 subgraph endpoint on The Graph is a dedicated API that provides indexed blockchain data for Uniswap v3. It allows developers to query trading pairs, liquidity pools, swaps, and other DeFi metrics efficiently. The endpoint is hosted on The Graph’s decentralized network, ensuring reliable access to real-time and historical data.
How do I query the Uniswap v3 subgraph using the official endpoint?
To query the Uniswap v3 subgraph, you need to send GraphQL requests to the official endpoint. First, define your query structure—for example, retrieving pool data or swap history. Then, use a tool like GraphiQL, Apollo Client, or a simple HTTP request to fetch the data. The endpoint URL is typically provided in The Graph’s documentation or Uniswap’s developer resources.
Is the Uniswap v3 subgraph endpoint free to use?
Yes, the Uniswap v3 subgraph endpoint is free to query, but rate limits may apply depending on The Graph’s network conditions. For high-volume applications, you might need to set up a dedicated subgraph or use The Graph’s paid services for better performance.
What kind of data can I get from the Uniswap v3 subgraph?
The Uniswap v3 subgraph provides detailed on-chain data, including liquidity pool statistics, token swaps, fees, and positions. You can track trading volumes, historical price changes, and user activity. This data is useful for building analytics dashboards, trading bots, or monitoring DeFi market trends.
Are there any alternatives to the official Uniswap v3 subgraph?
If the official endpoint is unavailable or slow, you can deploy your own subgraph instance or use third-party indexing services. Some developers also rely on direct blockchain RPC calls, though this requires more effort to process raw data. Always check Uniswap’s GitHub or The Graph’s hosted services for updated alternatives.
What is the Uniswap v3 subgraph official endpoint on The Graph?
The Uniswap v3 subgraph official endpoint on The Graph is a dedicated API that allows developers to query indexed blockchain data related to Uniswap v3. It provides structured access to information like pools, swaps, liquidity positions, and fees. The endpoint is hosted on The Graph’s decentralized network, ensuring reliable and efficient data retrieval for applications built on Uniswap v3.
How can I use the Uniswap v3 subgraph in my project?
To use the Uniswap v3 subgraph, you need to send GraphQL queries to its official endpoint. First, identify the data you need—such as trade volumes or liquidity changes. Then, write a query specifying the fields you want. For example, you can fetch details about specific pools or token pairs. The subgraph documentation provides schema details and example queries to help you get started. Integrate the responses into your application to display or analyze Uniswap v3 data.
Reviews
Ethan Reynolds
Seriously? Another glorified promo piece pretending to be useful. The Graph’s docs already explain this stuff better, and yet here we are, rehashing the same basic info like it’s some groundbreaking revelation. Zero depth on actual pain points—like how often the endpoint chokes during high volatility or why queries still time out despite all the “optimizations.” And let’s not even talk about the lack of real-world examples or benchmarks. Feels like someone just copied the GitHub README and called it a day. If you’re gonna waste people’s time, at least bring something new to the table. This is lazy.
Charlotte
Wow, yet another endpoint for Uniswap v3—because obviously, we needed more ways to query data nobody actually uses. Bet this ‘official’ thing took ages to hype up, only to be as exciting as watching paint dry. Kudos to The Graph for making blockchain analytics feel like reading a tax manual. Real game changer, huh? Not.
James Carter
**”Hey folks, ever wondered how Uniswap v3’s Subgraph on The Graph actually works under the hood? Like, what makes it so reliable compared to running your own indexer? And if the official endpoint ever goes down, what’s Plan B—just pray or is there a fallback? Also, how much trust do we *really* need to put in a single centralized endpoint, even if it’s ‘official’? Would love to hear from devs who’ve built on this—any quirks, hidden costs, or surprises you’ve hit? Or is it all smooth sailing once you plug in?”** *(357 символов, включая пробелы.)*
Noah Fletcher
The Uniswap v3 subgraph on The Graph’s official endpoint is a solid tool for querying swap, liquidity, and price data. It’s useful for developers who need historical or real-time info without running their own node. The setup is straightforward if you’re familiar with GraphQL, though the schema can take some time to fully grasp. Performance is decent for most queries, but complex ones might slow down during high network activity. One thing I noticed is that the documentation covers the basics well, but deeper edge cases require trial and error. For projects relying heavily on Uniswap data, this subgraph saves a lot of backend work. It’s not perfect—sometimes there are minor delays in syncing—but it’s reliable enough for most use cases. If you’re building analytics or tracking liquidity, it’s worth integrating. Just keep an eye on rate limits if your app scales up.
IronPhoenix
*Ah, the sweet relief of not having to spin up another local instance just to query some swaps. Finally, an official endpoint that doesn’t make me feel like I’m debugging a Rube Goldberg machine. Sure, you could’ve rolled your own subgraph—if you enjoy the thrill of chasing down phantom schema errors at 3 AM. But why bother? Now we’ve got a sanctioned way to tap into Uniswap v3’s chaos without the existential dread of maintaining it. Bravo. Now, if only someone could explain why my LP positions still look like a bad abstract art piece.* (868 chars)