How to query metadata with GraphQL API
Metadata are relevant information regarding the scope of data in the GraphQL API. They can help you understand the relationship and the utility of the request processes.
To check GraphQL API’s metadata, you need to go through two steps: create a personal token and run your request on Postman. See the next sections and follow the presented steps.
Creating a personal token
Before running your requests with the GraphQL API, you first need to create a personal token to validate your access.
- On Real-Time Manager (RTM), select Account menu > Personal Tokens.
- Fill the fields to configure the personal token and click the Create Token button.
- Copy and save your token in a safe location to use it in the next section.
See the Personal Tokens documentation for more information on how to create one.
As an alternative, you can create a short-duration token through the Azion API.
Running metadata requests with Postman
After creating your personal token, go to Postman and follow the next steps:
- On the header, click the + button to create a new request.
- On the Headers tab, click on Bulk Edit and add the following code, replacing [TOKEN VALUE] with the personal token value you created:
Authorization:Token [TOKEN VALUE]
Remain on Postman and create the request’s body:
- Select the Body tab.
- On the upper-left corner, click the GET option to open a dropdown menu.
- Select the POST option.
- On the options row, select the GraphQL option.
- On the QUERY box, add the following IntrospectionQuery:
query introspectionQuery {
__type(name: "Query") {
name
description
fields {
name
description
type {
ofType {
fields {
name
type {
name
}
}
}
}
}
}
}
- On the Enter URL or paste text field, add the URL being queried:
https://api.azionapi.net/metrics/graphql
- Click the Send button on the upper-right corner.
After running your request, you’ll see the following information as a response:
{
"data": {
"__type": {
"name": "Query",
"description": "Class responsible for gathering the queries from the datasets and returning them in the form of graphql schema to the Django view.",
"fields": [
{
"name": "dataStreamedMetrics",
"description": "Query dataStreamed Aggregated with aggregate options.",
"type": {
"ofType": {
"fields": [
{
"name": "ts",
"type": {
"name": "CustomDateTime"
}
},
{
"name": "endpointType",
"type": {
"name": "String"
}
}
]
}
}
},
{
"name": "httpMetrics",
"description": "Query Http Aggregated with aggregate options.",
"type": {
"ofType": {
"fields": [
{
"name": "ts",
"type": {
"name": "CustomDateTime"
}
},
{
"name": "configurationId",
"type": {
"name": "String"
}
}
]
}
}
}
]
}
}
}
The API returns the following metadata:
- Datasets available to query, such as dataStreamedMetrics and httpMetrics.
- Available fields for each dataset query.
- Each type for returnable fields, such as Int, String, DateTime, and so on.
For more information on the available datasets with the GraphQL API, visit the datasets documentation page.
Watch a video tutorial on consulting metadada with GraphQL on Azion’s YouTube channel:
Didn’t find what you were looking for? Open a support ticket.