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

# Quest API Reference

> Query quest information and check user eligibility for quest requirements

## Overview

The Quest API provides access to quest information, user eligibility verification, and quest metadata.

## Core Queries

### Get Quest Details

```graphql theme={null}
query GetQuest($id: ID!) {
  quest(id: $id) {
    id
    name
    type
    status
    description
    startTime
    endTime
    cap
    participantsCount
    loyaltyPoints
    gasType
    space {
      id
      name
    }
    chain
  }
}
```

### List Space Quests

```graphql theme={null}
query GetSpaceQuests($input: ListQuestInput!) {
  quests(input: $input) {
    totalCount
    pageInfo {
      hasNextPage
      endCursor
    }
    list {
      id
      name
      type
      status
      participantsCount
      loyaltyPoints
      startTime
      endTime
    }
  }
}
```

**Variables**:

```json theme={null}
{
  "input": {
    "spaceId": "40",
    "statuses": ["Active", "NotStarted"],
    "types": ["Drop", "Points"],
    "first": 20
  }
}
```

### Check User Eligibility

```graphql theme={null}
query CheckQuestEligibility($questId: ID!, $address: String!) {
  quest(id: $questId) {
    id
    name
    status
    credentialGroups(address: $address) {
      id
      name
      conditionRelation
      conditions {
        expression
        eligible
      }
      rewards {
        expression
        eligible
        rewardType
        rewardCount
      }
    }
  }
}
```

**When all `conditions.eligible` are `true`, the user meets quest requirements.**

## Field Reference

### Quest Status

| Status       | Description                              |
| ------------ | ---------------------------------------- |
| `Draft`      | Quest in development, not visible        |
| `Active`     | Quest is live and accepting participants |
| `NotStarted` | Quest scheduled but not started          |
| `Expired`    | Quest period has ended                   |
| `CapReached` | Maximum participants reached             |
| `Deleted`    | Quest has been removed                   |

### Quest Types

| Type           | Description                  |
| -------------- | ---------------------------- |
| `Drop`         | Standard quest with rewards  |
| `MysteryBox`   | Random reward quest          |
| `Airdrop`      | Token distribution quest     |
| `Points`       | Loyalty points reward        |
| `ExternalLink` | External website integration |

### Gas Types

| Type      | Description           |
| --------- | --------------------- |
| `Gas`     | User pays gas fees    |
| `Gasless` | Galxe covers gas fees |

### Key Fields

| Field                       | Type                | Description                    |
| --------------------------- | ------------------- | ------------------------------ |
| `id`                        | `ID!`               | Quest's unique hash ID         |
| `name`                      | `String!`           | Quest display name             |
| `status`                    | `QuestStatus!`      | Current quest status           |
| `participantsCount`         | `Int!`              | Number of participants         |
| `loyaltyPoints`             | `Int!`              | Points awarded for completion  |
| `credentialGroups(address)` | `[CredentialGroup]` | User-specific eligibility data |

## Integration Patterns

### Basic Quest Validation

```bash theme={null}
curl -X POST https://graphigo-business.prd.galaxy.eco/query \
  -H "Content-Type: application/json" \
  -H "access-token: YOUR_ACCESS_TOKEN" \
  -d '{
    "query": "query GetQuest($id: ID!) { quest(id: $id) { name status participantsCount cap loyaltyPoints } }",
    "variables": { "id": "GChdWUjXX3" }
  }'
```

### Quest Status Validation

Check these conditions before allowing participation:

1. `status` must be `"Active"`
2. `participantsCount` must be less than `cap` (if cap > 0)
3. Current time must be between `startTime` and `endTime`

### User Eligibility Flow

1. Call `credentialGroups(address: $userAddress)`
2. Check each group's `conditions.eligible` values
3. If `conditionRelation` is `"ALL"`, all conditions must be `true`
4. If `conditionRelation` is `"ANY"`, at least one condition must be `true`

## Best Practices

1. **Status Validation**: Always check quest status before showing participation UI
2. **Capacity Check**: Verify `participantsCount < cap` for available spots
3. **Time Validation**: Ensure current time is within quest period
4. **Error Handling**: Handle quest not found and permission errors
5. **Caching**: Cache quest details for 1-5 minutes to reduce API calls

## Common Errors

| Error                   | Cause                 | Solution                |
| ----------------------- | --------------------- | ----------------------- |
| `Quest not found`       | Invalid quest ID      | Verify quest ID exists  |
| `Quest is private`      | No access permissions | Check quest permissions |
| `Rate limit exceeded`   | Too many requests     | Implement retry logic   |
| `Invalid status filter` | Wrong enum value      | Use valid status values |

## Next Steps

* **[Quest Integration Guide](/galxe-integration/guides/quests)** - Complete implementation patterns
* **[Credential API Reference](/galxe-integration/api-reference/credential)** - User verification
* **[Authentication](/galxe-integration/getting-started/authentication)** - Access token setup
