# Subgraph

### Overview

The Panda Protocol subgraph indexes and provides structured access to protocol data through a GraphQL API. This documentation will help you integrate with our data layer effectively.

### Understanding the Subgraph

The subgraph serves as the backbone for accessing Panda Protocol's on-chain data. It processes and indexes:

* Pool deployments and configurations
* Trading activities and price movements
* Liquidity positions and migrations
* Token holder balances and distributions

<img src="/files/jAMX8koVbHlJYJBBqdWn" alt="" class="gitbook-drawing">

### When to Use the Subgraph

#### Perfect For

* Building trading interfaces requiring real-time pool data
* Creating analytics dashboards with historical data
* Tracking pool performance and market metrics
* Monitoring token holder distributions

### Accessing the Subgraph

```typescript
https://api.goldsky.com/api/public/project_clpx84oel0al201r78jsl0r3i/subgraphs/kodiak-panda-berachain-mainnet/latest/gn
```

### Quick Example

```graphql
# Fetch active pools with their latest metrics
{
  pandaPools(
    where: { 
      graduated: false,
      volumeUSD_gt: "0"
    }
    orderBy: volumeUSD
    orderDirection: desc
  ) {
    id
    price
    volumeUSD
    swapsCount
  }
}
```

### Data Structure

The subgraph maintains several core entities:

* `PandaPool`: Pool state and metrics
* `Token`: Token details and statistics
* `Swap`: Trading activity records
* `Holder`: Token holder information

For detailed entity definitions, see our Entities documentation.

### Development Guides

1. Entity Relationships
   * Understanding data models
   * Entity relationships
   * Field references
2. Query Examples
   * Common queries
   * Filtering and sorting
   * Pagination patterns
3. Advanced Usage
   * Performance optimization
   * Error handling
   * Edge cases

### Next Steps

[→ Continue to Entity Documentation](/developers/panda/subgraph/entity-reference.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.kodiak.finance/developers/panda/subgraph.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
