---
name: azion-query-graphql-schema-metadata
description: >-
  List the datasets a GraphQL API endpoint serves, the fields of each dataset, and their types with an introspection query.
---

# Query GraphQL schema metadata

You can ask the [GraphQL API](/en/documentation/devtools/graphql/overview/) which datasets an endpoint serves, which fields each dataset returns, and the type of each field. The answer comes from an introspection query, which reads the schema instead of your data. Use it to check a dataset or field name before you write a query.

---

## Prerequisites

- A personal token. To create one, refer to [Manage a personal token](/en/documentation/guides/platform/account-and-billing/personal-tokens/).

---

## List datasets and their fields

Each endpoint describes only its own datasets. The steps below query `https://api.azion.com/v4/metrics/graphql`, which serves the metrics datasets. To list the datasets of another endpoint, such as `https://api.azion.com/v4/events/graphql`, send the same queries there.

To read the schema of the metrics endpoint:

1. **Send the introspection query**

   Send this query in a `POST` request to `https://api.azion.com/v4/metrics/graphql`, with the header `Authorization: Token [TOKEN VALUE]`. To send a query, refer to [GraphQL API quickstart](/en/documentation/devtools/graphql/first-steps/) or [Run GraphQL queries in Postman](/en/documentation/guides/platform/observability/query-graphql-postman/).

   ```graphql
   query introspectionQuery {
    __type(name: "Query") {
      name
      description
      fields {
          name
          description
          type {
              ofType {
                  fields {
                      name
                      type {
                          name
                         }
                     }
                 }
             }
         }
     }
   }
   ```

2. **Check the datasets in the response**

   The API answers with HTTP `200` and one entry per dataset in `fields`. The response below is cut after the third dataset, and after the third field of each dataset:

   ```json
   {
     "data": {
       "__type": {
         "name": "Query",
         "description": null,
         "fields": [
           {
             "name": "realTimeEventsQueriesMetrics",
             "description": "Real-Time Events Metrics dataset query by Minute, Hour and Day with aggregate options.",
             "type": {
               "ofType": {
                 "fields": [
                   {
                     "name": "ts",
                     "type": {
                       "name": "CustomDateTime"
                     }
                   },
                   {
                     "name": "sourceLocPop",
                     "type": {
                       "name": "String"
                     }
                   },
                   {
                     "name": "configurationId",
                     "type": {
                       "name": "Int"
                     }
                   },
                   …
                 ]
               }
             }
           },
           {
             "name": "aiMetrics",
             "description": "Query AI Metrics with aggregate options.",
             "type": {
               "ofType": {
                 "fields": [
                   {
                     "name": "ts",
                     "type": {
                       "name": "CustomDateTime"
                     }
                   },
                   {
                     "name": "sourceLocPop",
                     "type": {
                       "name": "String"
                     }
                   },
                   {
                     "name": "configurationId",
                     "type": {
                       "name": "Int"
                     }
                   },
                   …
                 ]
               }
             }
           },
           {
             "name": "objectStorageMetrics",
             "description": "Object Storage Metrics dataset query by Day with aggregate options.",
             "type": {
               "ofType": {
                 "fields": [
                   {
                     "name": "ts",
                     "type": {
                       "name": "CustomDateTime"
                     }
                   },
                   {
                     "name": "location",
                     "type": {
                       "name": "String"
                     }
                   },
                   {
                     "name": "bucketId",
                     "type": {
                       "name": "String"
                     }
                   },
                   …
                 ]
               }
             }
           },
           …
         ]
       }
     }
   }
   ```

3. **List the deprecated datasets**

   The first query leaves out deprecated datasets, such as `httpMetrics`, which `workloadMetrics` replaces. To list every dataset with its deprecation status, send this query to the same endpoint:

   ```graphql
   query {
     __type(name: "Query") {
       fields(includeDeprecated: true) { name isDeprecated deprecationReason }
     }
   }
   ```

   The API answers with HTTP `200`. The response below is cut after the third dataset:

   ```json
   {
     "data": {
       "__type": {
         "fields": [
           {
             "name": "realTimeEventsQueriesMetrics",
             "isDeprecated": false,
             "deprecationReason": null
           },
           {
             "name": "aiMetrics",
             "isDeprecated": false,
             "deprecationReason": null
           },
           {
             "name": "edgeAIMetrics",
             "isDeprecated": true,
             "deprecationReason": "Use aiMetrics instead."
           },
           …
         ]
       }
     }
   }
   ```

You have the name, description, and field list of each dataset the endpoint serves, and the replacement of each deprecated one.

---

## Read the response

Each key of the two responses describes one part of the schema:

| Key                                    | What it holds                                                                                                                     |
| -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `name`                                 | `Query`, the root type that holds every dataset of the endpoint.                                                                  |
| `description`                          | The description of the root type. It is `null`.                                                                                   |
| `fields[].name`                        | The name of a dataset, the name you put in a query.                                                                               |
| `fields[].description`                 | What the dataset holds. Most descriptions also name the time buckets the dataset groups data into, such as minute, hour, and day. |
| `fields[].type.ofType.fields`          | The fields the dataset returns, each with its `name` and the name of its type.                                                    |
| `type.name` of a field                 | The type of the field's value, such as `CustomDateTime` for `ts`, `String`, or `Int`.                                             |
| `isDeprecated` and `deprecationReason` | Whether a dataset is deprecated and, when it is, the dataset to use instead.                                                      |

---

## Next steps

- [Datasets and query arguments](/en/documentation/devtools/graphql/features.md): See every dataset by endpoint and the arguments each query accepts.
- [Real-Time Metrics fields](/en/documentation/devtools/graphql/gql-real-time-metrics-fields.md): Read what each field of the metrics datasets returns.
- [Real-Time Events fields](/en/documentation/devtools/graphql/gql-real-time-events-fields.md): Read what each field of the event datasets returns.
- [Queries](/en/documentation/devtools/graphql/queries.md): Write raw, aggregated, financial, and usage queries with the names you found.
