Execute public query
Execute an analytics query using a client's publishable key. Scoped to the client associated with the key. Supports the same query syntax as the admin endpoint but with client-level permissions.
curl -X POST "https://api.mythic-analytics.com/api/v1/public/query" \
-H "Content-Type: application/json" \
-H "X-Publishable-Key: YOUR_API_KEY" \
-d '{
"client_id": "acme-retail",
"metric": "page_views",
"dimensions": [
"day",
"country"
],
"filters": {
"url_contains": "/products",
"country": "US"
},
"period": "24h",
"from": "2024-12-25T10:00:00Z",
"to": "2024-12-25T10:00:00Z",
"limit": 42
}'
import requests
import json
url = "https://api.mythic-analytics.com/api/v1/public/query"
headers = {
"Content-Type": "application/json",
"X-Publishable-Key": "YOUR_API_KEY"
}
data = {
"client_id": "acme-retail",
"metric": "page_views",
"dimensions": [
"day",
"country"
],
"filters": {
"url_contains": "/products",
"country": "US"
},
"period": "24h",
"from": "2024-12-25T10:00:00Z",
"to": "2024-12-25T10:00:00Z",
"limit": 42
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.mythic-analytics.com/api/v1/public/query", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Publishable-Key": "YOUR_API_KEY"
},
body: JSON.stringify({
"client_id": "acme-retail",
"metric": "page_views",
"dimensions": [
"day",
"country"
],
"filters": {
"url_contains": "/products",
"country": "US"
},
"period": "24h",
"from": "2024-12-25T10:00:00Z",
"to": "2024-12-25T10:00:00Z",
"limit": 42
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"client_id": "acme-retail",
"metric": "page_views",
"dimensions": [
"day",
"country"
],
"filters": {
"url_contains": "/products",
"country": "US"
},
"period": "24h",
"from": "2024-12-25T10:00:00Z",
"to": "2024-12-25T10:00:00Z",
"limit": 42
}`)
req, err := http.NewRequest("POST", "https://api.mythic-analytics.com/api/v1/public/query", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Publishable-Key", "YOUR_API_KEY")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.mythic-analytics.com/api/v1/public/query')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['X-Publishable-Key'] = 'YOUR_API_KEY'
request.body = '{
"client_id": "acme-retail",
"metric": "page_views",
"dimensions": [
"day",
"country"
],
"filters": {
"url_contains": "/products",
"country": "US"
},
"period": "24h",
"from": "2024-12-25T10:00:00Z",
"to": "2024-12-25T10:00:00Z",
"limit": 42
}'
response = http.request(request)
puts response.body
{
"success": true,
"data": {
"columns": [
"day",
"page_views"
],
"rows": [
[
"2024-06-15",
1420
],
[
"2024-06-16",
1385
]
],
"total": 30
}
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
/public/query
Client publishable key. Format: pk_...
pk_...The media type of the request body
Client identifier to query data for.
Metric to aggregate (e.g., page_views, unique_visitors, events).
Dimensions to group results by.
Key-value filters to narrow query scope.
Time period. Default: 30d.
Custom period start (required when period is custom).
Custom period end (required when period is custom).
Maximum number of result rows. Default 1000.
Request Preview
Response
Response will appear here after sending the request
Authentication
API Key for authentication. Client publishable key. Format: pk_...
Body
Client identifier to query data for.
Metric to aggregate (e.g., page_views, unique_visitors, events).
Dimensions to group results by.
Key-value filters to narrow query scope.
Custom period start (required when period is custom).
Custom period end (required when period is custom).
Maximum number of result rows. Default 1000.
Responses
Last updated today