> ## Documentation Index
> Fetch the complete documentation index at: https://docs.codex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# getEventLabels

> Returns a list of event labels for a pair. Reference for the getEventLabels query in the Codex API: arguments, response fields, and usage.

## GraphQL

```
type Query {
  getEventLabels(
    id: String!
    limit: Int
    cursor: String
    direction: RankingDirection
  ): EventLabelConnection
}

type FrontRunLabelData {
  index: Int
  token0DrainedAmount: String!
  token1DrainedAmount: String!
}

type SandwichedLabelData {
  token0DrainedAmount: String
  token1DrainedAmount: String
}

union EventLabelData = FrontRunLabelData | SandwichedLabelData

enum EventLabelType {
  FrontRun
  Sandwiched
}

type EventLabel {
  data: EventLabelData!
  id: String!
  label: EventLabelType!
  logIndex: Int!
  networkId: Int!
  timestamp: Int!
  transactionIndex: Int!
  transactionHash: String!
}

type EventLabelConnection {
  items: [EventLabel]
  cursor: String
}

enum RankingDirection {
  ASC
  DESC
}
```

### Example

[Test this query in the Explorer →](https://docs.codex.io/explore.md)

```graphql theme={null}
{
  getEventLabels(
    id: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640:1"
    limit: 10
  ) {
    items {
      id
      label
      timestamp
      transactionHash
      networkId
      data {
        ... on FrontRunLabelData {
          token0DrainedAmount
          token1DrainedAmount
        }
        ... on SandwichedLabelData {
          sandwichedToken0Drained: token0DrainedAmount
          sandwichedToken1Drained: token1DrainedAmount
        }
      }
    }
    cursor
  }
}
```

### Usage Guidelines

* Pass the pair ID in `address:networkId` format to the `id` argument
* Results are ordered `DESC` by default; pass `direction: ASC` for oldest first
* Use the returned `cursor` with the `cursor` argument to paginate through results

### Related Recipes

* [Events](https://docs.codex.io/recipes/events.md): Build a token swap list with filtering, pagination, and real-time updates


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.