> ## 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.

# Examples

> For more information on our GraphQL endpoint, please refer to [this doc](/quest/graphql-api/overview).

# Space Access:

## Campaign

### Query campaign participants

Arguments:

| Name     | Description       |
| -------- | ----------------- |
| `id`     | Campaign hash id. |
| `pfirst` | Query limit.      |
| `pafter` | Query offset.     |

Request:

```graphql theme={null}
query campaignParticipants($id: ID!, $pfirst: Int!, $pafter: String!) {
  campaign(id: $id) {
    id
    numberID
    numNFTMinted
    participants {
      participants(first: $pfirst, after: $pafter) {
        list {
          address {
            username
            avatar
            address
            email
            solanaAddress
            aptosAddress
            seiAddress
            discordUserID
          }
        }
      }
      participantsCount
    }
  }
}
```

Variables:

```json theme={null}
{
  "id": "GCn45UjHXE",
  "pfirst": 1,
  "pafter": "-1"
}
```

Response:

```json theme={null}
{
  "data": {
    "campaign": {
      "id": "GCn45UjHXE",
      "numberID": 151178,
      "numNFTMinted": 0,
      "participants": {
        "participants": {
          "list": [
            {
              "address": {
                "username": "0xdoxes",
                "avatar": "https://source.boringavatars.com/marble/120/blunder8888@gmail.com",
                "address": "0x00000000ccd193975907ddb660b4692bb4257f9f",
                "email": "",
                "solanaAddress": "",
                "aptosAddress": "",
                "seiAddress": "",
                "discordUserID": ""
              }
            }
          ]
        },
        "participantsCount": 234163
      }
    }
  }
}
```

### Query NFT holder by campaign

Arguments:

| Name    | Description       |
| ------- | ----------------- |
| `id`    | Campaign hash id. |
| `block` | Chain block.      |
| `first` | Query limit.      |
| `after` | Query offset.     |

Request:

```graphql theme={null}
query NFTHolders($id: ID!, $block: Int!, $first: Int!, $after: String!) {
  campaign(id: $id) {
    nftHolderSnapshot {
      holders(block: $block, first: $first, after: $after) {
        list {
          id
          holder
        }
        totalCount
        edges {
          node {
            id
            holder
          }
          cursor
        }
        pageInfo {
          startCursor
          endCursor
          hasNextPage
          hasPreviousPage
        }
      }
    }
  }
}
```

Variables:

```json theme={null}
{
  "id": "GCCw3UD1eD",
  "block": 47291627,
  "first": 1,
  "after": "-1"
}
```

Response:

```json theme={null}
{
  "data": {
    "campaign": {
      "nftHolderSnapshot": {
        "holders": {
          "list": [
            {
              "id": "1",
              "holder": "0x102daf0f0b6c5f467dc0dab22c957c412e57b4aa"
            }
          ],
          "totalCount": 1,
          "edges": [
            {
              "node": {
                "id": "1",
                "holder": "0x102daf0f0b6c5f467dc0dab22c957c412e57b4aa"
              },
              "cursor": "1"
            }
          ],
          "pageInfo": {
            "startCursor": "1",
            "endCursor": "1",
            "hasNextPage": true,
            "hasPreviousPage": false
          }
        }
      }
    }
  }
}
```

### Create campaigns

Arguments:

| Name    | Description       |
| ------- | ----------------- |
| `input` | Campaign hash id. |

Request:

```graphql theme={null}
mutation addCampaign($input: MutateCampaignInput!) {
  campaign(input: $input) {
    id
    numberID
    name
    claimEndTime
  }
}
```

Variables:

```json theme={null}
{
  "input": {
    "daoId": 2,
    "nftCoreId": 0,
    "name": "eeeeee",
    "description": "eeeeee",
    "thumbnail": "",
    "startTime": 1694793600,
    "endTime": 1698336000,
    "status": "Active",
    "formula": "",
    "cap": 1,
    "gasType": "Gas",
    "isPrivate": true,
    "type": "Bounty",
    "requireIntegrate": false,
    "nftTemplates": [],
    "tokenReward": {
      "tokenLogo": "",
      "tokenDecimal": "",
      "userTokenAmount": "",
      "tokenAddress": "",
      "tokenSymbol": "",
      "tokenRewardId": 0
    },
    "children": [],
    "distributionType": "RAFFLE",
    "rewardName": "ee",
    "credentialGroups": [
      {
        "conditions": [
          {
            "expression": "true"
          }
        ],
        "conditionRelation": "ALL",
        "rewards": [
          {
            "expression": "5",
            "rewardType": "LOYALTYPOINTS"
          },
          {
            "expression": "1",
            "rewardType": "CUSTOM"
          }
        ],
        "credentials": []
      }
    ],
    "taskConfig": {
      "rewardConfigs": []
    },
    "rewardType": "EVM",
    "rewardInfo": {}
  }
}
```

Response:

```json theme={null}
{
  "data": {
    "campaign": {
      "id": "GCFEXUtxc1",
      "numberID": 5448,
      "name": "eeeeee",
      "claimEndTime": null
    }
  }
}
```

### Claim OAT campaigns on third-party website

Use GraphQL API get campaign info

Request:

```graphql theme={null}
mutation claim {
  prepareParticipate(
    input: {
      signature: "" # keep empty
      campaignID: "{{campaignHashID}}" # campaign hash id
      address: "{{userAddr}}" # user address
    }
  ) {
    allow # Is allow user claim nft
    disallowReason # Disallow reason
  }
}
```

Response:

```json theme={null}
{
  "data": {
    "prepareParticipate": {
      "allow": true,
      "disallowReason": ""
    }
  }
}
```

## Space

### Query campaign list

Arguments:

| Name            | Description             |
| --------------- | ----------------------- |
| `id`            | Space id.               |
| `alias`         | Space alias.            |
| `campaignInput` | Campaigns query params. |

Request:

```graphql theme={null}
query CampaignList(
  $id: Int
  $alias: String
  $campaignInput: ListCampaignInput!
) {
  space(id: $id, alias: $alias) {
    id
    name
    alias
    campaigns(input: $campaignInput) {
      pageInfo {
        endCursor
        hasNextPage
      }
      list {
        id
        name
      }
    }
  }
}
```

Variables:

```json theme={null}
{
  "alias": "bnbchain",
  "campaignInput": {
    "forAdmin": false,
    "first": 2,
    "after": "-1",
    "excludeChildren": true,
    "gasTypes": null,
    "credSources": null,
    "rewardTypes": null,
    "chains": null,
    "statuses": null,
    "listType": "Newest",
    "types": [
      "Drop",
      "MysteryBox",
      "Forge",
      "MysteryBoxWR",
      "Airdrop",
      "ExternalLink",
      "OptIn",
      "OptInEmail",
      "PowahDrop",
      "Parent",
      "Oat",
      "Bounty",
      "Token",
      "DiscordRole",
      "Mintlist",
      "Points",
      "PointsMysteryBox"
    ],
    "searchString": null
  }
}
```

Response:

```json theme={null}
{
  "data": {
    "space": {
      "id": "40",
      "name": "BNB Chain",
      "alias": "bnbchain",
      "campaigns": {
        "pageInfo": {
          "endCursor": "1",
          "hasNextPage": true
        },
        "list": [
          {
            "id": "GCU8jUP7RS",
            "name": "BNB Chain Ecosystem Catalyst Awards -  Trailblazers"
          },
          {
            "id": "GCis8Uj4gL",
            "name": "BNB Chain 3 YA NFT "
          }
        ]
      }
    }
  }
}
```

### Query NFT holder by contract

Arguments:

| Name      | Description       |
| --------- | ----------------- |
| `address` | Contract address. |
| `first`   | Query limit.      |
| `after`   | Query offset.     |

Request:

```graphql theme={null}
query nftHolders($address: String!, $first: Int!, $after: String!) {
  nftCore(address: $address) {
    holders(first: $first, after: $after) {
      totalCount
      pageInfo {
        startCursor
        endCursor
        hasNextPage
        hasPreviousPage
      }
      list {
        address
      }
    }
  }
}
```

Variables:

```json theme={null}
{
  "address": "0x9d3895D07bF07A791Ef8d015Ab10997D22179E5c",
  "first": 2,
  "after": "-1"
}
```

Response:

```json theme={null}
{
  "data": {
    "nftCore": {
      "holders": {
        "totalCount": 3,
        "pageInfo": {
          "startCursor": "0",
          "endCursor": "1",
          "hasNextPage": true,
          "hasPreviousPage": false
        },
        "list": [
          {
            "address": "0x000000000A38444e0a6E37d3b630d7e855a7cb13"
          },
          {
            "address": "0x00000015E180b01c40b881e10774Bc784bB6F4Eb"
          }
        ]
      }
    }
  }
}
```

### Query leaderboard data

#### Overall

Arguments:

| Name          | Description                                                                                                                                            |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `id`          | Space id.                                                                                                                                              |
| `pageSize`    | Query limit.                                                                                                                                           |
| `cursorAfter` | You don't need to pass in this value on the first page. On the second page, you can start passing in the `endCursor` value returned by the first page. |
| `order`       | Sort by Points/GalxeID.                                                                                                                                |
| `seasonId`    | Query for season ranking. Overall ranking is null                                                                                                      |

Request:

```graphql theme={null}
query SpaceLeaderboard(
  $id: Int!,
  $pageSize: Int,
  $order: LoyaltyPointsRankOrder,
  $cursorAfter: String,
  $seasonId: Int
) {
  space(id: $id) {
    id
    name
    loyaltyPointsRanks(
      first: $pageSize
      order: $order
      cursorAfter: $cursorAfter
      sprintId: $seasonId
    ) {
      pageInfo {
        startCursor
        endCursor
        hasNextPage
        hasPreviousPage
        __typename
      }
      totalCount
      edges {
        node {
          id
          rank
          points
          space {
            name
            __typename
          }
          address {
            username
            id
            avatar
            address
            solanaAddress
            aptosAddress
            seiAddress
            twitterUserName
            discordUserName
            displayNamePref
            displayTwitter
            displayDiscord
            __typename
          }
          __typename
        }
        __typename
      }
      __typename
    }
    __typename
  }
}
```

Variables:

```json theme={null}
{
  "id": 40,
  "pageSize": 2,
  "cursorAfter": "Mg==",
  "order": "Points",
  "seasonId": null
}
```

Response:

```json theme={null}
{
  "data": {
    "space": {
      "id": "40",
      "name": "BNB Chain",
      "loyaltyPointsRanks": {
        "pageInfo": {
          "startCursor": "Mw==",
          "endCursor": "NA==",
          "hasNextPage": true,
          "hasPreviousPage": true,
          "__typename": "PageInfo"
        },
        "totalCount": 5509,
        "edges": [
          {
            "node": {
              "id": "lbrank-DJkB89vLsPMm44LuraURi8-40",
              "rank": 2,
              "points": 180,
              "space": {
                "name": "BNB Chain",
                "__typename": "Space"
              },
              "address": {
                "username": "DJkB89vLsPMm44LuraURi8",
                "id": "DJkB89vLsPMm44LuraURi8",
                "avatar": "https://cdn.galxe.com/galaxy/score/c6096a05-45f3-4427-8961-3326f9812ae1.png",
                "address": "0x1fa5b7fc4da7777d211ed41d31f8b84735fd41b1",
                "solanaAddress": "",
                "aptosAddress": "",
                "seiAddress": "",
                "twitterUserName": "",
                "discordUserName": "",
                "displayNamePref": "USERNAME",
                "displayTwitter": false,
                "displayDiscord": false,
                "__typename": "Address"
              },
              "__typename": "LoyaltyPointsRank"
            },
            "__typename": "LoyaltyPointsRankEdge"
          },
          {
            "node": {
              "id": "lbrank-XHKvqqv82igAiiWjA7TEHH-40",
              "rank": 2,
              "points": 180,
              "space": {
                "name": "BNB Chain",
                "__typename": "Space"
              },
              "address": {
                "username": "tiepvien1111",
                "id": "XHKvqqv82igAiiWjA7TEHH",
                "avatar": "https://cdn.galxe.com/galaxy/score/30c28119-a45d-4591-ad22-436726404634.png",
                "address": "0x3739734419c979730fb0d0a4da42a840010e3cb1",
                "solanaAddress": "",
                "aptosAddress": "",
                "seiAddress": "",
                "twitterUserName": "",
                "discordUserName": "",
                "displayNamePref": "USERNAME",
                "displayTwitter": false,
                "displayDiscord": false,
                "__typename": "Address"
              },
              "__typename": "LoyaltyPointsRank"
            },
            "__typename": "LoyaltyPointsRankEdge"
          }
        ],
        "__typename": "LoyaltyPointsRankConnection"
      },
      "__typename": "Space"
    }
  }
}
```

### Query leaderboard data for one address

Arguments:

| Name       | Description                                       |
| ---------- | ------------------------------------------------- |
| `id`       | Space id.                                         |
| `seasonId` | Query for season ranking. Overall ranking is null |

Request:

```graphql theme={null}
query SpaceLoyaltyPoints(
  $id: Int,
  $address: String!,
  $seasonId: Int) {
  space(id: $id) {
    id
    addressLoyaltyPoints(address: $address, sprintId: $seasonId) {
      id
      points
      rank
    }
  }
}
```

Variables:

```json theme={null}
{
  "id": 40,
  "address": "0x1fa5b7fc4da7777d211ed41d31f8b84735fd41b1",
  "seasonId": null
}
```

Response:

```json theme={null}
{
  "data": {
    "space": {
      "id": "40",
      "addressLoyaltyPoints": {
        "id": "sa-lb-0x1fa5b7fc4da7777d211ed41d31f8b84735fd41b1-40",
        "points": 180,
        "rank": 2
      }
    }
  }
}
```

### Distribute loyalty points

Prerequisite:
generate an access token

```graphql theme={null}
mutation UpdateAccessToken($input: UpdateAccessTokenInput!) {
  updateAccessToken(input: $input) {
    accessToken
  }
}
```

```json theme={null}
{
  "input": {
    "address": "0x39b36ff83b60eb54d71758cffa3ab17d2d0b216c"
  }
}
```

```json theme={null}
{
  "data": {
    "updateAccessToken": {
      "access-token": "your-access-token"
    }
  }
}
```

Task Creation

Header:

```json theme={null}
{
  "access-token": "your-access-token"
}
```

Request:

```graphql theme={null}
mutation createTask {
  createTailoredTask(
    input: {
      title: "Connect to Galxe"
      description: "A user who connected to Galxe.com"
      link: "your_link"
      spaceId: 2
      tag: Once
      points: 10
      startTime: 0
    }
  ) {
    id
    title
    description
    link
    spaceId
    tag
    points
    startTime
  }
}
```

Response

```graphql theme={null}
{
  "data": {
    "createTailoredTask": {
      "id": "26",
      "title": "Connect to Galxe",
      "description": "A user who connected to Galxe.com",
      "link": "your_link",
      "spaceId": 2,
      "tag": "Once",
      "points": 10,
      "startTime": 0
    }
  }
}
```

Task Modification

Header:

```json theme={null}
{
  "access-token": "your-access-token"
}
```

Request:

```graphql theme={null}
mutation updateTask {
  updateTailoredTask(
    input: {
      id: 26
      title: "update task title"
      description: "desc"
      link: "your_link"
      points: 10
      tag: Once
      startTime: 0
    }
  )
}
```

Response:

```graphql theme={null}
{
  "data": {
    "updateTailoredTask": true
  }
}
```

Task Deletion

Header:

```json theme={null}
{
  "access-token": "your-access-token"
}
```

Request:

```graphql theme={null}
mutation deleteTask {
  deleteTailoredTask(id: 26)
}
```

Distributing Points via API

Request:

```graphql theme={null}
mutation {
  claimTailoredTaskLoyaltyPoints(
    id: 25
    addresses: [
      "0x447D24B00937BCc3fE5768c828fb2fae52c3e8C5"
      "0xaC1F963Ed7454d0D3295786E4Bcc47B961918C63"
    ]
  )
}
```

Response:

```graphql theme={null}
{
  "data": {
    "claimTailoredTaskLoyaltyPoints": true
  }
}
```

## Credential

### Query credential items

Header:

```json theme={null}
{
  "access-token": "your-access-token"
}
```

```graphql theme={null}
query CredItems($id: ID!, $first: Int, $after: String, $searchString: String) {
  credential(id: $id) {
    id
    itemCount
    credentialItems(first: $first, after: $after, searchString: $searchString) {
      totalCount
      pageInfo {
        endCursor
        hasNextPage
      }
      list
    }
  }
}
```

example variables:

```
{id: "2544", first: 500, after: ""}
```

# Open Access:

## User

### Query profile and credential

```graphql theme={null}
query ProfileCredentials($address: String!, $first: Int, $after: String) {
  addressInfo(address: $address) {
    addressEligibleCredentials(first: $first, after: $after) {
      pageInfo {
        endCursor
        hasNextPage
      }
      totalCount
      list {
        id
        name
      }
    }
  }
}
```

## Credential

### Get credential value

Depends on `credSource`, metadata field should use corresponding field.

E.g. if `credSource` is `SPACE_USER`, then the query should look like the following:

```graphql theme={null}
query credential($id: ID!, $eligibleAddress: String!) {
  credential(id: $id, eligibleAddress: $eligibleAddress) {
    name
    credSource
    dimensionConfig
    metadata {
      spaceUsers {
        spaceId
        schema {
          follow {
            id
            description
            title
            type
          }
          points {
            id
            description
            title
            type
          }
          participations {
            id
            description
            title
            type
          }
        }
        defaultValue {
          follow
          points
          participations
        }
      }
    }
    value {
      address
      spaceUsers {
        follow
        points
        participations
      }
    }
  }
}
```

## Campaign

### Query campaign participants

Arguments:

| Name     | Description       |
| -------- | ----------------- |
| `id`     | Campaign hash id. |
| `pfirst` | Query limit.      |
| `pafter` | Query offset.     |

Request:

```graphql theme={null}
query campaignParticipants($id: ID!, $pfirst: Int!, $pafter: String!) {
  campaign(id: $id) {
    id
    numberID
    numNFTMinted
    participants {
      participants(first: $pfirst, after: $pafter) {
        list {
          address {
            username
            avatar
            address
            email
            solanaAddress
            aptosAddress
            seiAddress
            discordUserID
          }
        }
      }
      participantsCount
    }
  }
}
```

Variables:

```json theme={null}
{
  "id": "GCn45UjHXE",
  "pfirst": 1,
  "pafter": "-1"
}
```

Response:

```json theme={null}
{
  "data": {
    "campaign": {
      "id": "GCn45UjHXE",
      "numberID": 151178,
      "numNFTMinted": 0,
      "participants": {
        "participants": {
          "list": [
            {
              "address": {
                "username": "0xdoxes",
                "avatar": "https://source.boringavatars.com/marble/120/blunder8888@gmail.com",
                "address": "0x00000000ccd193975907ddb660b4692bb4257f9f",
                "email": "",
                "solanaAddress": "",
                "aptosAddress": "",
                "seiAddress": "",
                "discordUserID": ""
              }
            }
          ]
        },
        "participantsCount": 234163
      }
    }
  }
}
```

## Space

### Query campaign list

Arguments:

| Name            | Description             |
| --------------- | ----------------------- |
| `id`            | Space id.               |
| `alias`         | Space alias.            |
| `campaignInput` | Campaigns query params. |

Request:

```graphql theme={null}
query CampaignList(
  $id: Int
  $alias: String
  $campaignInput: ListCampaignInput!
) {
  space(id: $id, alias: $alias) {
    id
    name
    alias
    campaigns(input: $campaignInput) {
      pageInfo {
        endCursor
        hasNextPage
      }
      list {
        id
        name
      }
    }
  }
}
```

Variables:

```json theme={null}
{
  "alias": "bnbchain",
  "campaignInput": {
    "forAdmin": false,
    "first": 2,
    "after": "-1",
    "excludeChildren": true,
    "gasTypes": null,
    "credSources": null,
    "rewardTypes": null,
    "chains": null,
    "statuses": null,
    "listType": "Newest",
    "types": [
      "Drop",
      "MysteryBox",
      "Forge",
      "MysteryBoxWR",
      "Airdrop",
      "ExternalLink",
      "OptIn",
      "OptInEmail",
      "PowahDrop",
      "Parent",
      "Oat",
      "Bounty",
      "Token",
      "DiscordRole",
      "Mintlist",
      "Points",
      "PointsMysteryBox"
    ],
    "searchString": null
  }
}
```

Response:

```json theme={null}
{
  "data": {
    "space": {
      "id": "40",
      "name": "BNB Chain",
      "alias": "bnbchain",
      "campaigns": {
        "pageInfo": {
          "endCursor": "1",
          "hasNextPage": true
        },
        "list": [
          {
            "id": "GCU8jUP7RS",
            "name": "BNB Chain Ecosystem Catalyst Awards -  Trailblazers"
          },
          {
            "id": "GCis8Uj4gL",
            "name": "BNB Chain 3 YA NFT "
          }
        ]
      }
    }
  }
}
```
