> For the complete documentation index, see [llms.txt](https://docs.nosto.com/techdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nosto.com/techdocs/apis/graphql-an-introduction/graphql-using-queries/graphql-querying-segments.md).

# Querying Segments

You can query all the configured segments using the GraphQL Segments endpoint. You are able to query all the names and identifiers of the segments.

```graphql
curl -0 -v -X POST https://api.nosto.com/v1/graphql \
-u ":<token>" \
-H 'Content-Type: application/graphql' \
-d @- << EOF
query {
  segments{
    segments{
      id,
      name
    },
    affinities{
      topBrands{
        name,
        score
      },
      topCategories{
        name,
        score
      },
      topProductTypes{
        name,
        score
      },
      topSkus {
        attribute,
        values{
          name,
          score
        }
      }
    }
  }
}
EOF
```

## Sample Output

```javascript
{
  "data": {
    "segments": {
      "segments": [
        {
          "id": "5a497a000000000000000001",
          "name": "First-Time Visitors"
        },
        {
          "id": "5b71f1500000000000000006",
          "name": "Returning Visitors"
        },
        {
          "id": "5a497a000000000000000002",
          "name": "Prospects"
        },
        {
          "id": "5a497a000000000000000003",
          "name": "First-Time Customers"
        },
        {
          "id": "5a497a000000000000000004",
          "name": "Repeat Customers"
        },
        {
          "id": "5a497a000000000000000005",
          "name": "Loyal Customers"
        },
        {
          "id": "5a497a000000000000000000",
          "name": "All Customers"
        }
      ],
      "affinities": {
        "topBrands": [
          {
            "name": "Amazing Brand",
            "score": 0.6
          }
        ],
        "topCategories": [
          {
            "name": "/accessories",
            "score": 0.4
          }
        ],
        "topProductTypes": [
          {
            "name": "accessory",
            "score": 0.53
          }
        ],
        "topSkus": [
          {
            "attribute": "size",
            "values": [
              {
                "name": "36",
                "score": 0.5
              }
            ]
          },
          {
            "attribute": "color",
            "values": [
              {
                "name": "green",
                "score": 0.8
              }
            ]
          }
        ]
      }
    }
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nosto.com/techdocs/apis/graphql-an-introduction/graphql-using-queries/graphql-querying-segments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
