# 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="https://584145091-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOSwqNrRJ9Xh6jO57yoLm%2Fuploads%2FFR7lW1UD2UCWnkp20HWr%2Ffile.excalidraw.svg?alt=media&#x26;token=7155f0be-2ca1-4d7b-b4b3-d185d825979d" 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](https://documentation.kodiak.finance/developers/panda/subgraph/entity-reference)
