> This page is for Beam.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://mediakind.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://mediakind.ferndocs.com/_mcp/server.

# Query Metrics

GET https://app.mk.io/api/channel-metrics/query/

Execute arbitrary PromQL range query. Returns Prometheus format.

Reference: https://mediakind.ferndocs.com/beam/api/channels/metrics/query-metrics

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Query parameters

- `query` (string, required) — PromQL query
- `start` (string, required) — Start time (ISO8601 or Unix timestamp)
- `end` (string, required) — End time (ISO8601 or Unix timestamp)
- `step` (string, optional, default: 60s) — Query resolution step (e.g. 60s, 5m, 1h)

## Response

### 200

Successful Response

- `status` (string, required) — 'success' or 'error'
- `data` (PrometheusMatrixData, optional, nullable) — Data section of a matrix response.
- `error` (string, optional, nullable) — Error message if status is 'error'
- `errorType` (string, optional, nullable)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### PrometheusMatrixData

Data section of a matrix response.

- `result` (list of PrometheusMatrixResult, required)
- `resultType` (string, optional, default: matrix)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### PrometheusMatrixResult

Single result in a matrix response.

- `metric` (PrometheusMetricLabels, required) — Metric labels from Prometheus. Allows arbitrary labels.
- `values` (list of list of string, required) — Array of [unix_timestamp, value_string] pairs

### ValidationErrorLocItems

### ValidationErrorCtx

### PrometheusMetricLabels

Metric labels from Prometheus. Allows arbitrary labels.

- `serverID` (string, optional, nullable)
- `name` (string, optional, nullable)
- `job` (string, optional, nullable)

## Examples

**Response**

```json
{
  "status": "string",
  "data": {
    "result": [
      {
        "metric": {
          "serverID": "string",
          "name": "string",
          "job": "string"
        },
        "values": [
          [
            "string"
          ]
        ]
      }
    ],
    "resultType": "matrix"
  },
  "error": "string",
  "errorType": "string"
}
```

**SDK Code**

```python
import requests

url = "https://app.mk.io/api/channel-metrics/query/"

querystring = {"end":"end","query":"query","start":"start"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://app.mk.io/api/channel-metrics/query/?end=end&query=query&start=start';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://app.mk.io/api/channel-metrics/query/?end=end&query=query&start=start"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.mk.io/api/channel-metrics/query/?end=end&query=query&start=start")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://app.mk.io/api/channel-metrics/query/?end=end&query=query&start=start")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.mk.io/api/channel-metrics/query/?end=end&query=query&start=start', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.mk.io/api/channel-metrics/query/?end=end&query=query&start=start");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.mk.io/api/channel-metrics/query/?end=end&query=query&start=start")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```