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

# Search new communities

Opigno Enterprise API provides an endpoint to get all communities the current API user can join.

<Note>
  Only public communities will be returned in the query results.
</Note>

To get the list of communities available for searching, `searchNewCommunities` query should be called.
The results will be returned with the pagination and possibility to change the order (default sorting is by the title, 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`   | `Integer`          | Returns up to the first N elements from the list. Required if `after` parameter is set. Cannot be used together with `last`.                                                                             | —       |
| `last`    | `Integer`          | 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` | `CommunitySortKey` | Sort the underlying list by the given key. By default communities will be sorted by the title. Available options can be found [here](/OpignoEnterpriseAPI/Community/GetCommunities#community-sort-keys). | `TITLE` |
| `title`   | `String`           | Allows to search by the community title.                                                                                                                                                                 | —       |

<CodeGroup>
  ```filename GraphQL theme={null}
    query searchNewCommunities {
      searchNewCommunities(first: 2) {
        edges {
          node {
            id
            title
            visibility
            description
            cta {
              actionId
              arguments {
                key
                value
              }
            }
            ownerUserContext {
              displayName
              id
              uuid
            }
          }
        }
      }
    }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "getCommunities": {
        "edges": [
          {
            "node": {
              "id": "1",
              "title": "The first community",
              "visibility": "PUBLIC",
              "description": "<p>The first community description.</p>\n",
              "cta": [
                {
                  "actionId": "JOIN_COMMUNITY",
                  "arguments": [
                    {
                      "key": "communityId",
                      "value": "1"
                    }
                  ]
                },
              ],
              "ownerUserContext": {
                "displayName": "John Doe",
                "id": "1",
                "uuid": "b004e1a8-ec3d-40ec-bf05-8b54a99875a1"
              }
            }
          }
        ]
      }
    }
  }
  ```
</CodeGroup>

The query returns the list of the `Communtiy` objects. Detailed description and the full list of available properties can be found [here](/OpignoEnterpriseAPI/Community/GetCommunity).
