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

# Get the list of challenges

Use query `getChallenges` to implement different challenge listings:

1. completed by the current API user;
2. ongoing (the current date is between start and end dates, AND the challenge is not completed by the current API user yet);
3. upcoming (the start date is in the future);
4. all available challenges (except those ones that are finished and not completed by the current API user).

In a response it returns a list of [`Challenge`](/OpignoEnterpriseAPI/Challenge/GetChallenge#challenge-api-object) objects
that fit the applied filters.

Results will be returned with the pagination and possibility to change the order and sorting key (default sorting is by the start date, ascending).

The following arguments can be used in the query:

| Argument          | Type               | Description                                                                                                                                                                                                     | Default      |
| :---------------- | :----------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------- |
| `after`           | `Cursor`           | Returns results that come after the specified cursor. Should be used together with `first` parameter. Cannot be used if `before` is set.                                                                        | —            |
| `before`          | `Cursor`           | Returns results that come before the specified cursor. Should be used together with `last` parameter. Cannot be used if `after` is set.                                                                         | —            |
| `first`           | `Int`              | Returns up to the first N elements from the list. Required if `after` parameter is set. Cannot be used together with `last`.                                                                                    | —            |
| `last`            | `Int`              | Returns up to the first N elements from the list. Required if `before` parameter is set. Cannot be used together with `first`.                                                                                  | —            |
| `reverse`         | `Boolean`          | Allows to reverse the order of the underlying list (default order is ascending).                                                                                                                                | `false`      |
| `sortKey`         | `ChallengeSortKey` | Allows to change the results sorting. Available options: `START_DATE` (default), `END_DATE`                                                                                                                     | `START_DATE` |
| `status`          | `ChallengeStatus`  | Provides the possibility to filter by the challenge status. Available options: `COMPLETED`, `ONGOING`, `UPCOMING`.  Leave empty to get all available challenges; missed ones will be excluded from the results. | —            |
| `userContextUuid` | `ID`               | The user context UUID to get the list of challenges for. If omitted, the results will be retrieved for the current API user context.                                                                            | —            |

Here is an example of the query execution:

<CodeGroup>
  ```filename GraphQL theme={null}
  query getChallenges {
    getChallenges(first: 10, status: "COMPLETED") {
      edges {
        node {
          id
          title
          questionsNumber
          startDate
          endDate
          isRankingEnabled
          cta {
            actionId
            title
            arguments {
              key
              value
            }
          }
        }
      }
      totalItems
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "getChallenges": {
        "edges": [
          {
            "node": {
              "id": 1,
              "title": "Check your geography knowledge",
              "questionsNumber": 10,
              "startDate": 1770595200,
              "endDate": 1773100799,
              "isRankingEnabled": true,
              "cta": [
                {
                  "actionId": "VIEW_CHALLENGE",
                  "title": "See details",
                  "arguments": [
                    {
                      "key": "challengeId",
                      "value": "1"
                    }
                  ]
                },
                {
                  "actionId": "VIEW_CHALLENGE_RESULTS",
                  "title": "View full results",
                  "arguments": [
                    {
                      "key": "challengeId",
                      "value": "1"
                    }
                  ]
                }
              ]
            }
          }
          {
            "node": {
              "id": 2,
              "title": "Check your history knowledge",
              "questionsNumber": 15,
              "startDate": 1773100800,
              "endDate": 1774051199,
              "isRankingEnabled": false,
              "cta": [
                {
                  "actionId": "VIEW_CHALLENGE",
                  "title": "See details",
                  "arguments": [
                    {
                      "key": "challengeId",
                      "value": "2"
                    }
                  ]
                },
                {
                  "actionId": "VIEW_CHALLENGE_RESULTS",
                  "title": "View full results",
                  "arguments": [
                    {
                      "key": "challengeId",
                      "value": "2"
                    }
                  ]
                }
              ]
            }
          }
        ],
        "totalItems": 2
      }
    }
  }
  ```
</CodeGroup>

## Related Features

The `getChallenges` query supports the same advanced features as other catalog queries:

<CardGroup cols={2}>
  <Card title="Pagination" icon="arrow-right" href="/OpignoEnterpriseAPI/PaginatingCatalogItems">
    Learn how to efficiently navigate through large sets of items using cursor-based pagination.
  </Card>

  <Card title="Authentication" icon="key" href="/OpignoEnterpriseAPI/ConsumerUserAuthentication">
    Understand the authentication requirements and how to properly authenticate your requests.
  </Card>
</CardGroup>
